示例#1
0
        internal static IEnumerable <Func <DomainObject, object> > GetMethods(Type objType, string propertyName)
        {
            var attributes = DomainProperty.GetAttributes <PropertyGetAttribute>(objType, propertyName);

            List <Func <DomainObject, object> > methods = new List <Func <DomainObject, object> >(attributes.Count());

            foreach (var attribute in attributes)
            {
                methods.Add(attribute.GetAction());
            }
            return(methods);
        }
        /// <summary>
        /// 根据属性标记的验证器特性,得到验证器
        /// </summary>
        /// <returns></returns>
        internal static IEnumerable <IPropertyValidator> GetValidators(Type objType, string propertyName)
        {
            var attributes = DomainProperty.GetAttributes <PropertyValidatorAttribute>(objType, propertyName);

            List <IPropertyValidator> validators = new List <IPropertyValidator>(attributes.Count());

            foreach (var attr in attributes)
            {
                validators.Add(attr.CreateValidator());
            }
            return(validators);
        }