private void addAttributes(IMemberInfo memberInfo, AssociationAttribute associationAttribute, ProvidedAssociationAttribute providedAssociationAttribute, XPCustomMemberInfo customMemberInfo) { customMemberInfo.AddAttribute(getAssociationAttribute(customMemberInfo.IsCollection, memberInfo.Owner.Type,associationAttribute.Name)); if (providedAssociationAttribute.AttributesFactoryProperty != null){ var property = memberInfo.Owner.Type.GetProperty(providedAssociationAttribute.AttributesFactoryProperty, BindingFlags.Static|BindingFlags.Public); if (property== null) throw new NullReferenceException(string.Format("Static propeprty {0} not found at {1}", providedAssociationAttribute.GetPropertyInfo(x=>x.AttributesFactoryProperty).Name, memberInfo.Owner.Type.FullName)); var values = (IEnumerable<Attribute>) property.GetValue(null, null); foreach (Attribute attribute in values){ customMemberInfo.AddAttribute(attribute); } } }
private XPCustomMemberInfo GetCustomMemberInfo(IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute) { XPCustomMemberInfo customMemberInfo; var typeToCreateOn = getTypeToCreateOn(memberInfo,associationAttribute); if (typeToCreateOn== null) throw new NotImplementedException(); var propertyName = providedAssociationAttribute.ProvidedPropertyName??typeToCreateOn.Name+"s"; if (memberInfo.IsAssociation || (memberInfo.IsList&&providedAssociationAttribute.RelationType==RelationType.ManyToMany)){ customMemberInfo = XafTypesInfo.Instance.CreateCollection(typeToCreateOn, memberInfo.Owner.Type, propertyName,XafTypesInfo.XpoTypeInfoSource.XPDictionary); } else customMemberInfo = XafTypesInfo.Instance.CreateMember(typeToCreateOn, memberInfo.Owner.Type, propertyName, XafTypesInfo.XpoTypeInfoSource.XPDictionary); return customMemberInfo; }