10using System.ComponentModel;
11using System.ComponentModel.DataAnnotations;
89 public PropertyInfo(
string name,
string friendlyName,
Type containingType, T defaultValue)
126 _friendlyName = friendlyName;
127 _relationshipType = relationship;
128 if (containingType !=
null)
129 _propertyInfo = containingType.GetProperty(
Name);
131 _defaultValue = defaultValue;
137 public string Name {
get;
private set; }
144 get {
return typeof(T); }
147 private readonly System.Reflection.PropertyInfo _propertyInfo;
149 private readonly
string _friendlyName;
163 string result =
Name;
164 if (!
string.IsNullOrWhiteSpace(_friendlyName))
166 result = _friendlyName;
168 else if (_propertyInfo !=
null)
170 var display = _propertyInfo.GetCustomAttributes(typeof(DisplayAttribute),
true).OfType<DisplayAttribute>().FirstOrDefault();
174 result = display.GetName();
179 var displayName = _propertyInfo.GetCustomAttributes(typeof(DisplayNameAttribute),
true).OfType<DisplayNameAttribute>().FirstOrDefault();
180 if (displayName !=
null)
181 result = displayName.DisplayName;
188 private readonly T _defaultValue;
200 get {
return _defaultValue; }
203 object Core.IPropertyInfo.DefaultValue
208 Core.FieldManager.IFieldData Core.IPropertyInfo.NewFieldData(
string name)
210 return NewFieldData(name);
221 protected virtual Core.FieldManager.IFieldData
NewFieldData(
string name)
223 return new Core.FieldManager.FieldData<T>(name);
236 get {
return _relationshipType; }
239 private int _index = -1;
246 int Core.IPropertyInfo.Index
248 get {
return _index; }
249 set { _index = value; }
256 public bool IsChild {
get => typeof(Core.IBusinessObject).IsAssignableFrom(
Type); }
259 #region IComparable Members
261 int IComparable.CompareTo(
object obj)
263 return Name.CompareTo(((Core.IPropertyInfo)obj).Name);
275 if (typeof(T) == typeof(
string))
276 return (T)(object)
string.Empty;
Maintains metadata about a property.
virtual T DefaultValue
Gets the default initial value for the property.
PropertyInfo(string name)
Creates a new instance of this class.
RelationshipTypes RelationshipType
Gets the relationship between the declaring object and the object reference in the property.
PropertyInfo(string name, string friendlyName, Type containingType, T defaultValue)
Creates a new instance of this class.
PropertyInfo(string name, T defaultValue)
Creates a new instance of this class.
Type Type
Gets the type of the property.
static T DataBindingFriendlyDefault()
Creates the CSLA Data Binding Friendly default for the given type T.
PropertyInfo(string name, string friendlyName, Type containingType, T defaultValue, RelationshipTypes relationship)
Creates a new instance of this class.
string Name
Gets the property name value.
PropertyInfo(string name, RelationshipTypes relationship)
Creates a new instance of this class.
bool IsChild
Gets a value indicating whether this property references a child in the object graph.
virtual string FriendlyName
Gets the friendly display name for the property.
PropertyInfo(string name, string friendlyName, Type containingType)
Creates a new instance of this class.
virtual Core.FieldManager.IFieldData NewFieldData(string name)
Create and return a new IFieldData object to store an instance value for this property.
PropertyInfo(string name, string friendlyName, Type containingType, RelationshipTypes relationship)
Creates a new instance of this class.
PropertyInfo(string name, string friendlyName)
Creates a new instance of this class.
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...