private XPCustomMemberInfo CreateMemberInfo(ITypesInfo typesInfo, IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute) { var typeToCreateOn = getTypeToCreateOn(memberInfo, associationAttribute); if (typeToCreateOn == null) throw new NotImplementedException(); XPCustomMemberInfo xpCustomMemberInfo; if (!(memberInfo.IsList) || (memberInfo.IsList && providedAssociationAttribute.RelationType == RelationType.ManyToMany)) { xpCustomMemberInfo = typesInfo.CreateCollection( typeToCreateOn, memberInfo.Owner.Type, associationAttribute.Name, XpandModuleBase.Dictiorary, providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.Type.Name + "s", false); } else { xpCustomMemberInfo = typesInfo.CreateMember( typeToCreateOn, memberInfo.Owner.Type, associationAttribute.Name, XpandModuleBase.Dictiorary, providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.Type.Name, false); } if (!string.IsNullOrEmpty(providedAssociationAttribute.AssociationName) && memberInfo.FindAttribute<AssociationAttribute>() == null) memberInfo.AddAttribute(new AssociationAttribute(providedAssociationAttribute.AssociationName)); typesInfo.RefreshInfo(typeToCreateOn); return xpCustomMemberInfo; }
AssociationAttribute GetAssociationAttribute(IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute) { var associationAttribute = memberInfo.FindAttribute<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 AddExtraAttributes(XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, XPMemberInfo customMemberInfo) { if (!(string.IsNullOrEmpty(providedAssociationAttribute.AttributesFactoryProperty))) foreach (var attribute in GetAttributes(providedAssociationAttribute.AttributesFactoryProperty, memberInfo.Owner)) { customMemberInfo.AddAttribute(attribute); } }