예제 #1
0
 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);
         }
     }
 }
예제 #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
        private XPMemberInfo CreateMemberInfo(ITypesInfo typesInfo, XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute)
        {
            var typeToCreateOn = GetTypeToCreateOn(memberInfo, associationAttribute);

            if (typeToCreateOn == null)
            {
                throw new NotImplementedException();
            }
            XPMemberInfo xpCustomMemberInfo;

            if (!(memberInfo.IsNonAssociationList) || (memberInfo.IsNonAssociationList && providedAssociationAttribute.RelationType == RelationType.ManyToMany))
            {
                xpCustomMemberInfo = typesInfo.CreateCollection(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name + "s", false);
            }
            else
            {
                xpCustomMemberInfo = typesInfo.CreateMember(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name, false);
            }

            if (!string.IsNullOrEmpty(providedAssociationAttribute.AssociationName) && !memberInfo.HasAttribute(typeof(AssociationAttribute)))
            {
                memberInfo.AddAttribute(new AssociationAttribute(providedAssociationAttribute.AssociationName));
            }

            typesInfo.RefreshInfo(typeToCreateOn);

            return(xpCustomMemberInfo);
        }