示例#1
0
        public static List <XPCustomMemberInfo> CreateBothPartMembers(this ITypesInfo typesinfo, Type typeToCreateOn, Type otherPartMember, XPDictionary xpDictionary, bool isManyToMany, string association,
                                                                      string createOnPropertyName, string otherPartPropertyName)
        {
            var infos = new List <XPCustomMemberInfo>();
            XPCustomMemberInfo member = isManyToMany
                                            ? CreateCollection(typesinfo, typeToCreateOn, otherPartMember, association,
                                                               xpDictionary, false, createOnPropertyName, true)
                                            : CreateMember(typesinfo, typeToCreateOn, otherPartMember, association, xpDictionary, createOnPropertyName, false);

            if (member != null)
            {
                infos.Add(member);
                member = isManyToMany
                             ? CreateCollection(typesinfo, otherPartMember, typeToCreateOn, association, xpDictionary,
                                                false, otherPartPropertyName, true)
                             : CreateCollection(typesinfo, typeToCreateOn, otherPartMember, association, xpDictionary,
                                                false, otherPartPropertyName);

                if (member != null)
                {
                    infos.Add(member);
                }
            }

            typesinfo.RefreshInfo(typeToCreateOn);
            typesinfo.RefreshInfo(otherPartMember);
            return(infos);
        }
示例#2
0
        public static List <XPMemberInfo> CreateBothPartMembers(this ITypesInfo typesinfo, Type typeToCreateOn, Type otherPartMember, bool isManyToMany, string association)
        {
            var          infos  = new List <XPMemberInfo>();
            XPMemberInfo member = isManyToMany
                                            ? CreateCollection(typesinfo, typeToCreateOn, otherPartMember, association, false)
                                            : CreateMember(typesinfo, otherPartMember, typeToCreateOn, association, false);

            if (member != null)
            {
                infos.Add(member);
                member = isManyToMany
                             ? CreateCollection(typesinfo, otherPartMember, typeToCreateOn, association, false)
                             : CreateCollection(typesinfo, typeToCreateOn, otherPartMember, association, false);

                if (member != null)
                {
                    infos.Add(member);
                }
            }

            typesinfo.RefreshInfo(typeToCreateOn);
            typesinfo.RefreshInfo(otherPartMember);

            return(infos);
        }
示例#3
0
        public override void CustomizeTypesInfo(ITypesInfo typesInfo)
        {
            base.CustomizeTypesInfo(typesInfo);

            CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);

            foreach (var type in XafTypesInfo.Instance.PersistentTypes)
            {
                ModelNodesGeneratorSettings.SetIdPrefix(type.Type, type.FullName);
            }

            foreach (var ci in typesInfo.PersistentTypes)
            {
                if (!ci.IsPersistent)
                {
                    continue;
                }

                /*var tableName = TranslatePersistentName( ci.AssemblyInfo.FullName, ci.Name );
                 * ci.AddAttribute( new PersistentAttribute( tableName ) );*/

                var oidMember = ci.FindMember("Oid");
                if (oidMember != null)
                {
                    var browsableAttribute = oidMember.FindAttribute <BrowsableAttribute>( );
                    if (browsableAttribute == null)
                    {
                        oidMember.AddAttribute(new BrowsableAttribute(false));
                    }

                    typesInfo.RefreshInfo(ci);
                }
            }
        }
示例#4
0
 protected void CreateDesignTimeCollection(ITypesInfo typesInfo, Type classType, string propertyName) {
     XPClassInfo info = XafTypesInfo.XpoTypeInfoSource.XPDictionary.GetClassInfo(classType);
     if (info.FindMember(propertyName) == null) {
         info.CreateMember(propertyName, typeof(XPCollection), true);
         typesInfo.RefreshInfo(classType);
     }
 }
        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;
        }
示例#6
0
 static void RefreshTypes(ITypesInfo typesInfo, IEnumerable <ITypeInfo> typeInfos)
 {
     foreach (var typeInfo in typeInfos)
     {
         typesInfo.RefreshInfo(typeInfo);
     }
 }
示例#7
0
        static XPMemberInfo CreateCollection(this ITypesInfo typeInfo, Type typeToCreateOn, Type typeOfCollection, string associationName, XPDictionary dictionary, string collectionName, bool refreshTypesInfo,
                                             bool isManyToMany)
        {
            XPMemberInfo member = null;

            if (TypeIsRegister(typeInfo, typeToCreateOn))
            {
                XPClassInfo xpClassInfo = dictionary.GetClassInfo(typeToCreateOn);
                member = xpClassInfo.FindMember(collectionName);
                if (member == null)
                {
                    member = xpClassInfo.CreateMember(collectionName, typeof(XPCollection), true);
                    member.AddAttribute(new AssociationAttribute(associationName, typeOfCollection)
                    {
                        UseAssociationNameAsIntermediateTableName = isManyToMany
                    });

                    if (refreshTypesInfo)
                    {
                        typeInfo.RefreshInfo(typeToCreateOn);
                    }
                }
            }
            return(member);
        }
        public void CreateMembers(Session session, ITypesInfo typesInfo) {
            _typesInfo = typesInfo;
            var types = CreateCollectionMembers(session);
            types.AddRange(CreateReferenceMembers(session));
            types.AddRange(CreateCoreMembers(session));

            foreach (var type in types.Distinct()) {
                typesInfo.RefreshInfo(type);
            }
        }
示例#9
0
        protected void CreateDesignTimeCollection(ITypesInfo typesInfo, Type classType, string propertyName)
        {
            XPClassInfo info = XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.GetClassInfo(classType);

            if (info.FindMember(propertyName) == null)
            {
                info.CreateMember(propertyName, typeof(XPCollection), true);
                typesInfo.RefreshInfo(classType);
            }
        }
示例#10
0
 public static void XafExtenderRegisterTypes(this ITypesInfo TypeInfo, IEnumerable <Type> types)
 {
     DevExpress.ExpressApp.DC.TypeInfo MyDynamicType;
     foreach (Type type in types)
     {
         MyDynamicType = (DevExpress.ExpressApp.DC.TypeInfo)TypeInfo.FindTypeInfo(type);
         MyDynamicType.RemoveAttributes <NonPersistentAttribute>();
         TypeInfo.RefreshInfo(type);
     }
 }
示例#11
0
        protected XafBuilderManager(ITypesInfo typesInfo)
        {
            var builders = BuildUpModel(typesInfo);

            _Builders.AddRange(builders);

            Build();

            foreach (var builder in _Builders.OfType <ITypeInfoProvider>())
            {
                typesInfo.RefreshInfo(builder.TypeInfo);
            }
        }
示例#12
0
        public void CreateMembers(Session session, ITypesInfo typesInfo)
        {
            _typesInfo = typesInfo;
            var types = CreateCollectionMembers(session);

            types.AddRange(CreateReferenceMembers(session));
            types.AddRange(CreateCoreMembers(session));

            foreach (var type in types.Distinct())
            {
                typesInfo.RefreshInfo(type);
            }
        }
示例#13
0
        public override void CustomizeTypesInfo(ITypesInfo typesInfo)
        {
            base.CustomizeTypesInfo(typesInfo);
            var ti   = typesInfo.FindTypeInfo(typeof(DevExpress.Persistent.BaseImpl.BaseObject));
            var bi   = (DevExpress.ExpressApp.DC.BaseInfo)ti.FindMember("Oid");
            var attr = bi.FindAttribute <System.ComponentModel.BrowsableAttribute>();

            bi.RemoveAttribute(attr);
            bi.AddAttribute(new DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false));
            bi.AddAttribute(new DevExpress.Persistent.Base.VisibleInListViewAttribute(false));
            bi.AddAttribute(new DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false));
            typesInfo.RefreshInfo(ti);
            CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
        }
示例#14
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,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name + "s", false);
            }
            else
            {
                xpCustomMemberInfo = typesInfo.CreateMember(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    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);
            typesInfo.RefreshInfo(memberInfo.Owner.ClassType);

            return(xpCustomMemberInfo);
        }
示例#15
0
        private static void CreateXpandDefaultProperty(ITypesInfo typesInfo)
        {
            var infos = typesInfo.PersistentTypes.Select(info => new{ TypeInfo = info, Attribute = info.FindAttribute <XpandDefaultPropertyAttribute>() })
                        .Where(arg => arg.Attribute != null).ToList();

            foreach (var info in infos.Where(arg => arg.TypeInfo.Base.FindAttribute <XpandDefaultPropertyAttribute>() == null))
            {
                var classInfo  = Dictiorary.GetClassInfo(info.TypeInfo.Type);
                var memberInfo = new XpandCalcMemberInfo(classInfo, info.Attribute.MemberName, typeof(string), info.Attribute.Expression);
                if (info.Attribute.InVisibleInAllViews)
                {
                    memberInfo.AddAttribute(new InvisibleInAllViewsAttribute());
                }
                typesInfo.RefreshInfo(info.TypeInfo);
                ((TypeInfo)info.TypeInfo).DefaultMember = info.TypeInfo.FindMember(info.Attribute.MemberName);
            }
        }
示例#16
0
        public override void CustomizeTypesInfo(ITypesInfo typesInfo)
        {
            base.CustomizeTypesInfo(typesInfo);

            foreach (var typeInfo in typesInfo.PersistentTypes)
            {
                // Add AggregatedAttribute to composition properties
                foreach (var memberInfo in typeInfo.OwnMembers.Where(m => m.IsProperty))
                {
                    var prop    = typeInfo.Type.GetProperty(memberInfo.Name);
                    var oppInfo = memberInfo.AssociatedMemberInfo;
                    if (oppInfo != null)
                    {
                        var opp = oppInfo.Owner.Type.GetProperty(oppInfo.Name);
                        if (opp.GetCustomAttribute <RequiredAttribute>() != null)
                        {
                            memberInfo.AddAttribute(new AggregatedAttribute(), true);
                        }
                    }
                }

                // Add uniqueness checks
                var propAttrs = from prop in typeInfo.OwnMembers
                                select new { prop, attr = prop.Owner.Type.GetProperty(prop.Name).GetCustomAttribute <UniqueIndexAttribute>() };
                var keys = from pa in propAttrs
                           where pa.attr != null
                           group pa by pa.attr.Name;
                foreach (var key in keys)
                {
                    if (key.Count() == 1)
                    {
                        key.First().prop.AddAttribute(new RuleUniqueValueAttribute(), true);
                    }
                    else
                    {
                        typeInfo.AddAttribute(new RuleCombinationOfPropertiesIsUniqueAttribute(
                                                  String.Join(", ", key.OrderBy(k => k.attr.Order).Select(k => k.prop.Name))));
                    }
                }

                typesInfo.RefreshInfo(typeInfo);
            }
        }
示例#17
0
        public static XPMemberInfo CreateMember(this ITypesInfo typesInfo, Type typeToCreateOn, Type typeOfMember, string associationName, string propertyName, bool refreshTypesInfo)
        {
            XPMemberInfo member = null;

            if (TypeIsRegister(typesInfo, typeToCreateOn))
            {
                XPClassInfo xpClassInfo = typesInfo.FindTypeInfo(typeToCreateOn).QueryXPClassInfo();
                member = xpClassInfo.FindMember(propertyName);
                if (member == null)
                {
                    member = xpClassInfo.CreateMember(propertyName, typeOfMember,
                                                      new AssociationAttribute(associationName, typeOfMember));
                    if (refreshTypesInfo)
                    {
                        typesInfo.RefreshInfo(typeToCreateOn);
                    }
                }
            }
            return(member);
        }
示例#18
0
        public static XPCustomMemberInfo CreateMember(this ITypesInfo typesInfo, Type typeToCreateOn, Type typeOfMember, string associationName, XPDictionary dictionary, string propertyName, bool refreshTypesInfo)
        {
            XPCustomMemberInfo member = null;

            if (typeIsRegister(typesInfo, typeToCreateOn))
            {
                XPClassInfo xpClassInfo = dictionary.GetClassInfo(typeToCreateOn);
                if (xpClassInfo.FindMember(propertyName) == null)
                {
                    member = xpClassInfo.CreateMember(propertyName, typeOfMember);
                    member.AddAttribute(new AssociationAttribute(associationName));

                    if (refreshTypesInfo)
                    {
                        typesInfo.RefreshInfo(typeToCreateOn);
                    }
                }
            }
            return(member);
        }
示例#19
0
 static void RefreshTypes(ITypesInfo typesInfo, IEnumerable<ITypeInfo> typeInfos) {
     foreach (var typeInfo in typeInfos) {
         typesInfo.RefreshInfo(typeInfo);
     }
 }