コード例 #1
0
        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;
        }