public string Validate(string property)
        {
            XPMemberInfo member = fValidatedObject.ClassInfo.FindMember(property);

            if (member == null)
            {
                return(string.Empty);
            }
            CustomAttribute attribute = (CustomAttribute)member.FindAttributeInfo("Validation");

            if (attribute == null)
            {
                return(string.Empty);
            }
            string[] rules    = attribute.Value.Substring(0, attribute.Value.IndexOf('|')).Split(';');
            string[] messages = attribute.Value.Substring(attribute.Value.IndexOf('|') + 1).Split(';');
            for (int i = 0; i < rules.Length; i++)
            {
                if (!ValidateRule(member, rules[i]))
                {
                    return(messages[i]);
                }
            }
            return(string.Empty);
        }
コード例 #2
0
 AssociationAttribute GetAssociationAttribute(XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute) {
     var associationAttribute = memberInfo.FindAttributeInfo(typeof(AssociationAttribute)) as AssociationAttribute;
     if (associationAttribute == null && !string.IsNullOrEmpty(providedAssociationAttribute.AssociationName))
         associationAttribute = new AssociationAttribute(providedAssociationAttribute.AssociationName);
     else if (associationAttribute == null)
         throw new NullReferenceException(memberInfo + " has no association attribute");
     return associationAttribute;
 }
コード例 #3
0
ファイル: ImportData.cs プロジェクト: xyyhqq/eXpand
        void CreateMemberFromAttribute(XPClassInfo classInfo, XPMemberInfo memberInfo, bool caseInSensitive)
        {
            var initialDataAttribute = (InitialDataAttribute)memberInfo.FindAttributeInfo(typeof(InitialDataAttribute));

            if (initialDataAttribute != null)
            {
                CreateMemberCore(classInfo, initialDataAttribute.Name ?? memberInfo.Name, memberInfo, caseInSensitive);
            }
        }
コード例 #4
0
        AssociationAttribute GetAssociationAttribute(XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute)
        {
            var associationAttribute = memberInfo.FindAttributeInfo(typeof(AssociationAttribute)) as AssociationAttribute;

            if (associationAttribute == null && !string.IsNullOrEmpty(providedAssociationAttribute.AssociationName))
            {
                associationAttribute = new AssociationAttribute(providedAssociationAttribute.AssociationName);
            }
            else if (associationAttribute == null)
            {
                throw new NullReferenceException(memberInfo + " has no association attribute");
            }
            return(associationAttribute);
        }
コード例 #5
0
ファイル: TypesInfoExtensions.cs プロジェクト: xyyhqq/eXpand
        static XPMemberInfo CreateCollection(this ITypesInfo typeInfo, Type typeToCreateOn, Type typeOfCollection, string associationName, string collectionName, bool refreshTypesInfo,
                                             bool isManyToMany)
        {
            XPMemberInfo member = null;

            if (TypeIsRegister(typeInfo, typeToCreateOn))
            {
                XPClassInfo xpClassInfo = typeInfo.FindTypeInfo(typeToCreateOn).QueryXPClassInfo();
                member = xpClassInfo.FindMember(collectionName) ??
                         xpClassInfo.CreateMember(collectionName, typeof(XPCollection), true);
                if (member.FindAttributeInfo(typeof(AssociationAttribute)) == null)
                {
                    member.AddAttribute(new AssociationAttribute(associationName, typeOfCollection)
                    {
                        UseAssociationNameAsIntermediateTableName = isManyToMany
                    });
                }
                if (refreshTypesInfo)
                {
                    typeInfo.RefreshInfo(typeToCreateOn);
                }
            }
            return(member);
        }
コード例 #6
0
ファイル: ImportData.cs プロジェクト: dimajanzen/eXpand
 void CreateMemberFromAttribute(XPClassInfo classInfo, XPMemberInfo memberInfo) {
     var initialDataAttribute = (InitialDataAttribute)memberInfo.FindAttributeInfo(typeof(InitialDataAttribute));
     if (initialDataAttribute != null) {
         CreateMemberCore(classInfo, initialDataAttribute.Name ?? memberInfo.Name, memberInfo);
     }
 }
コード例 #7
0
ファイル: XpandPermissionData.cs プロジェクト: xyyhqq/eXpand
 bool AttributesMatch(XPMemberInfo info)
 {
     return(info.FindAttributeInfo(typeof(NonPersistentAttribute)) == null && info.FindAttributeInfo(typeof(VisibleInListViewAttribute)) == null);
 }
コード例 #8
0
 bool AttributesMatch(XPMemberInfo info) {
     return info.FindAttributeInfo(typeof(NonPersistentAttribute)) == null && info.FindAttributeInfo(typeof(VisibleInListViewAttribute)) == null;
 }