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;
        }
예제 #2
0
        public void An_Associated_Member_Can_Be_Created_To_Any_Perstent_type()
        {
            ITypesInfo info           = XafTypesInfo.Instance;
            Type       typeToCreateOn = typeof(User);

            info.RegisterEntity(typeToCreateOn);
            Type typeOfMember = typeof(Analysis);

            XPCustomMemberInfo member = info.CreateMember(typeToCreateOn, typeOfMember, "association", XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary);

            assertMemberCreation(member, typeOfMember.Name, typeToCreateOn);
        }
예제 #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);
        }