Esempio n. 1
0
 public override void CustomizeTypesInfo(ITypesInfo typesInfo)
 {
     base.CustomizeTypesInfo(typesInfo);
     CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
 }
Esempio n. 2
0
        public override void CustomizeTypesInfo(ITypesInfo typesInfo)
        {
            base.CustomizeTypesInfo(typesInfo);
            CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);



            //typesInfo.FindTypeInfo(typeof(SearchFormBase)).AddAttribute(new DevExpress.Persistent.Base.DefaultClassOptionsAttribute());

            ////Dennis: simple creation of a new member.
            ///



            var EntityTypeTypeInfo = typesInfo.PersistentTypes.Cast <TypeInfo>().FirstOrDefault(pt => pt.Name == "EntityType");
            var SearchableClass    = typesInfo.PersistentTypes.Cast <TypeInfo>().Where(pt => pt.FindAttribute <SearchableClass>() != null);

            foreach (var item in SearchableClass)
            {
                var members = item.Members.Where(m => m.FindAttribute <SearchAttribute>() != null);
                foreach (var member in members)
                {
                    var SearchParameters = member.FindAttribute <SearchAttribute>();
                    if (SearchParameters.IsRange)
                    {
                        var FromMember = typesInfo.FindTypeInfo(typeof(SearchFormBase)).CreateMember($"From{member.Name}", member.MemberType);
                        FromMember.AddAttribute(new DetailViewLayoutAttribute(LayoutColumnPosition.Left));
                        var ToMember = typesInfo.FindTypeInfo(typeof(SearchFormBase)).CreateMember($"To{member.Name}", member.MemberType);
                        FromMember.AddAttribute(new DetailViewLayoutAttribute(LayoutColumnPosition.Right));
                    }
                    else
                    {
                        var SingleValue = typesInfo.FindTypeInfo(typeof(SearchFormBase)).CreateMember($"{member.Name}", member.MemberType);
                        SingleValue.AddAttribute(new DetailViewLayoutAttribute(LayoutColumnPosition.Right));
                    }
                }
            }


            ////Dennis: establishing a One-To-Many relationship between two classes.



            //XPDictionary xpDictionary = DevExpress.ExpressApp.Xpo.XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary;

            //XPClassInfo classInfo = xpDictionary.CreateClass(xpDictionary.GetClassInfo(typeof(SearchFormBase)), "MyClass");
            //XPMemberInfo memberInfo = classInfo.CreateMember("MyProperty", typeof(string),false,false);


            //XafTypesInfo.Instance.RefreshInfo(classInfo.ClassType);


            //if (xpDictionary.GetClassInfo(typeof(PersistentObject1)).FindMember("PersistentObject2s") == null)
            //{
            //    xpDictionary.GetClassInfo(typeof(PersistentObject1)).CreateMember("PersistentObject2s", typeof(XPCollection<PersistentObject2>), true,
            //        new AggregatedAttribute(), new AssociationAttribute("PersistentObject1-PersistentObject2s", typeof(PersistentObject2)));
            //}
            //if (xpDictionary.GetClassInfo(typeof(PersistentObject2)).FindMember("PersistentObject1") == null)
            //{
            //    xpDictionary.GetClassInfo(typeof(PersistentObject2)).CreateMember("PersistentObject1", typeof(PersistentObject1), new AssociationAttribute("PersistentObject1-PersistentObject2s"));
            //}
            ////Dennis: take special note of the fact that you have to refresh information about type, only if you made the changes in the XPDictionary. If you made the changes directly in the TypeInfo, refreshing is not necessary.
            XafTypesInfo.Instance.RefreshInfo(typeof(SearchFormBase));
            //XafTypesInfo.Instance.RefreshInfo(typeof(PersistentObject2));
        }