예제 #1
0
        public GenericMetadata <T> WithMemberDependency(Expression <Func <T, object> > property, Expression <Func <T, object> > dependsOn)
        {
            if (PropertyDependencies == null)
            {
                PropertyDependencies = new DependencyRegistrations();
            }

            PropertyDependencies.Add(new DependencyRegistration(property.GetFullPropertyName(), dependsOn.GetFullPropertyName()));
            return(this);
        }
예제 #2
0
        private static DependencyRegistrations GetDependencies(Type type)
        {
            var attrs = from member in type.GetRuntimeProperties()
                        let attr = member.GetCustomAttribute <DependsOnAttribute>()
                                   where attr != null
                                   select new { prop = member.Name, dep = attr.PropertyName };


            var registrations = new DependencyRegistrations();

            foreach (var dependsOnAttribute in attrs)
            {
                registrations.Add(new DependencyRegistration(dependsOnAttribute.prop, dependsOnAttribute.dep));
            }

            return(registrations);
        }