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); }
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; }
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); } }
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); }
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); }
void CreateMemberFromAttribute(XPClassInfo classInfo, XPMemberInfo memberInfo) { var initialDataAttribute = (InitialDataAttribute)memberInfo.FindAttributeInfo(typeof(InitialDataAttribute)); if (initialDataAttribute != null) { CreateMemberCore(classInfo, initialDataAttribute.Name ?? memberInfo.Name, memberInfo); } }
bool AttributesMatch(XPMemberInfo info) { return(info.FindAttributeInfo(typeof(NonPersistentAttribute)) == null && info.FindAttributeInfo(typeof(VisibleInListViewAttribute)) == null); }
bool AttributesMatch(XPMemberInfo info) { return info.FindAttributeInfo(typeof(NonPersistentAttribute)) == null && info.FindAttributeInfo(typeof(VisibleInListViewAttribute)) == null; }