public PropertyStorageDefinition(IPropertyStorageDefinition baseDefinition) { BaseDefinition = baseDefinition; if (baseDefinition != null) { FieldCount = baseDefinition.FieldCount; } }
internal static IEnumerable <PropertyAttribute> GetAll(this IPropertyStorageDefinition storage) { while (storage != null) { foreach (var attribute in storage.ClassAttributes.Where(a => !a.Reference)) { yield return(attribute); } storage = storage.BaseDefinition; } }
public Property(IPropertyStorageDefinition storage, Expression <Func <TOwner, TProperty> > property, Expression <Func <TOwner, TProperty> > get = null, Expression <Action <TOwner, TProperty> > set = null) { var body = property.Body as MemberExpression; PropertyInfo = (PropertyInfo)body.Member; Name = body.Member.Name; PropertyReference = property; var propertyAttributes = body.Member.GetCustomAttributes <PropertyAttribute>(false).Concat(PropertyInfo.PropertyType.GetCustomAttributes <PropertyAttribute>().Where(a => a.Reference)); var classAttributes = storage.GetAll(); StorageDefinition = storage; var all = GetAttributeList(propertyAttributes, classAttributes).ToArray(); var attributes = all.Aggregate((last, current) => { if (last != null) { current.Next = last; } return(current); }); attributes.Initialize <TOwner, TProperty, TProperty>(this); get = attributes.FilterGet <TOwner, TProperty, TProperty>(this); Get = get.Compile(); ToGet = get; set = attributes.FilterSet <TOwner, TProperty, TProperty>(this); Set = set.Compile(); ToSet = set; }
public PropertyStorage(IPropertyStorageDefinition definition) { Definition = definition; Values = new object[definition.FieldCount]; }