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