Files
Umbraco-CMS/umbraco/datalayer/Utility/Table/DefaultField.cs
Shandem f6d0d043b5 DO NOT DOWNLOAD. DOWNLOAT LATEST STABLE FROM RELEASE TAB
Created 4.1.0 branch

[TFS Changeset #55082]
2009-06-19 07:39:16 +00:00

88 lines
2.8 KiB
C#

using System;
namespace umbraco.DataLayer.Utility.Table
{
/// <summary>
/// Default implementation of the <see cref="IField"/> interface.
/// </summary>
public class DefaultField : IField
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DefaultField"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="dataType">Type of the data.</param>
/// <param name="size">The size of the field.</param>
/// <param name="properties">The properties.</param>
public DefaultField(string name, Type dataType, int size, FieldProperties properties)
{
if (String.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
if (dataType == null)
throw new ArgumentNullException("dataType");
Name = name;
DataType = dataType;
Properties = properties;
Size = size;
}
#endregion
#region IField Members
/// <summary>
/// Gets the name of the field.
/// </summary>
/// <value>The name.</value>
public virtual string Name { get; protected set; }
/// <summary>
/// Gets the data type of the field.
/// </summary>
/// <value>The field data type.</value>
public virtual Type DataType { get; protected set; }
/// <summary>
/// Gets the properties.
/// </summary>
/// <value>The properties.</value>
public virtual FieldProperties Properties { get; protected set; }
/// <summary>
/// Gets a value indicating the field size.
/// </summary>
/// <value>The size.</value>
public virtual int Size { get; protected set; }
/// <summary>
/// Determines whether the field has the specified property.
/// </summary>
/// <param name="property">The property.</param>
/// <returns><c>true</c> if the field has the property; otherwise, <c>false</c>.</returns>
public virtual bool HasProperty(FieldProperties property)
{
return (Properties & property) == property;
}
#endregion
#region object Members
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return String.Format("{0} ({1})", Name, DataType.FullName);
}
#endregion
}
}