Ejemplo n.º 1
0
 static void AddRuntimeMembers(IModelApplication model, XPDictionary dictionary)
 {
     foreach (IModelRuntimeMember modelRuntimeMember in GetCustomFields(model))
     {
         try {
             Type        classType = modelRuntimeMember.ModelClass.TypeInfo.Type;
             XPClassInfo typeInfo  = dictionary.GetClassInfo(classType);
             lock (typeInfo) {
                 if (typeInfo.FindMember(modelRuntimeMember.Name) == null)
                 {
                     XpandCustomMemberInfo memberInfo = GetMemberInfo(modelRuntimeMember, typeInfo);
                     AddAttributes(modelRuntimeMember, memberInfo);
                     XafTypesInfo.Instance.RefreshInfo(classType);
                 }
             }
         } catch (Exception exception) {
             throw new Exception(
                       ExceptionLocalizerTemplate <SystemExceptionResourceLocalizer, ExceptionId> .GetExceptionMessage(
                           ExceptionId.ErrorOccursWhileAddingTheCustomProperty,
                           modelRuntimeMember.MemberInfo.MemberType,
                           ((IModelClass)modelRuntimeMember.Parent).Name,
                           modelRuntimeMember.Name,
                           exception.Message));
         }
     }
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes the proxy.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <param name="appConnectionString">The app connection string.</param>
 /// <param name="secondStorageConnectionString">The replication storage connection string.</param>
 /// <param name="secondStorageTypes">The second storage types.</param>
 public void Initialize(XPDictionary dictionary, string appConnectionString,
     string secondStorageConnectionString, IEnumerable<Type> secondStorageTypes)
 {
     var secondStorageClasses = secondStorageTypes.Select(currentType => dictionary.GetClassInfo(currentType))
         .Where(classInfo => classInfo != null).ToList();
     Initialize(dictionary, appConnectionString, secondStorageConnectionString, secondStorageClasses);
 }
Ejemplo n.º 4
0
        public static void AddFields(DictionaryNode rootNode, XPDictionary dictionary)
        {
            foreach (PropertyInfoNodeWrapper customFieldInfo in GetCustomFields(rootNode))
                try
                {
                    Type classType = ReflectionHelper.GetType(customFieldInfo.Class.Name);
                    var typeInfo = dictionary.GetClassInfo(classType);
                    lock (typeInfo)
                    {
                        if (typeInfo.FindMember(customFieldInfo.Name) == null)
                        {
                            Type memberType = ReflectionHelper.GetType(customFieldInfo.Type);
                            XPCustomMemberInfo memberInfo = typeInfo.CreateMember(customFieldInfo.Name, memberType);
                            if (customFieldInfo.Size != 0)
                                memberInfo.AddAttribute(new DevExpress.Xpo.SizeAttribute(customFieldInfo.Size));

                            XafTypesInfo.Instance.RefreshInfo(classType);
                        }
                    }
                }
                catch (Exception exception)
                {
                    throw new Exception(
                        ExceptionLocalizerTemplate<SystemExceptionResourceLocalizer, ExceptionId>.GetExceptionMessage(
                            ExceptionId.ErrorOccursWhileAddingTheCustomProperty,
                            customFieldInfo.Type,
                            customFieldInfo.Class.Name,
                            customFieldInfo.Name,
                            exception.Message));
                }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes the proxy.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="appConnectionString">The app connection string.</param>
        /// <param name="secondStorageConnectionString">The replication storage connection string.</param>
        /// <param name="secondStorageTypes">The second storage types.</param>
        public void Initialize(XPDictionary dictionary, string appConnectionString,
                               string secondStorageConnectionString, IEnumerable <Type> secondStorageTypes)
        {
            var secondStorageClasses = secondStorageTypes.Select(currentType => dictionary.GetClassInfo(currentType))
                                       .Where(classInfo => classInfo != null).ToList();

            Initialize(dictionary, appConnectionString, secondStorageConnectionString, secondStorageClasses);
        }
        void CreateMembers(XPDictionary dictionary)
        {
            XPClassInfo ci = dictionary.GetClassInfo(AssemblyName, Name);

            foreach (PersistentMemberInfo mi in OwnMembers)
            {
                mi.CreateMember(ci);
            }
        }
Ejemplo n.º 7
0
 public static XPCustomMemberInfo CreateMember(this ITypesInfo typesInfo, Type typeToCreateOn, Type typeOfMember,
                                 string associationName, XPDictionary dictionary, string propertyName)
 {
     XPCustomMemberInfo member = null;
     if (typeIsRegister(typesInfo, typeToCreateOn)) {
         XPClassInfo xpClassInfo = dictionary.GetClassInfo(typeToCreateOn);
         member = xpClassInfo.CreateMember(propertyName, typeOfMember);
         member.AddAttribute(new AssociationAttribute(associationName));
         typesInfo.RefreshInfo(typeToCreateOn);
     }
     return member;
 }
Ejemplo n.º 8
0
 public static XPCustomMemberInfo CreateCollection(this ITypesInfo typeInfo, Type typeToCreateOn, Type typeOfCollection, string associationName, XPDictionary dictionary, string collectionName)
 {
     XPCustomMemberInfo member = null;
     if (typeIsRegister(typeInfo, typeToCreateOn))
     {
         XPClassInfo xpClassInfo = dictionary.GetClassInfo(typeToCreateOn);
         if (xpClassInfo.FindMember(collectionName)== null){
             member = xpClassInfo.CreateMember(collectionName, typeof(XPCollection), true);
             member.AddAttribute(new AssociationAttribute(associationName, typeOfCollection));
             typeInfo.RefreshInfo(typeToCreateOn);
         }
     }
     return member;
 }
        public XPClassInfo CreateClass(XPDictionary dictionary)
        {
            XPClassInfo result = dictionary.QueryClassInfo(AssemblyName, Name);

            if (result == null)
            {
                XPClassInfo baseClassInfo;
                if (BaseClass != null)
                {
                    baseClassInfo = BaseClass.CreateClass(dictionary);
                }
                else
                {
                    baseClassInfo = dictionary.GetClassInfo(GetDefaultBaseClass());
                }
                result = dictionary.CreateClass(baseClassInfo, Name);
                CreateAttributes(result);
            }
            return(result);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
 static void AddRuntimeMembers(IModelApplication model, XPDictionary dictionary) {
     foreach (IModelRuntimeMember modelRuntimeMember in GetCustomFields(model))
         try {
             Type classType = modelRuntimeMember.ModelClass.TypeInfo.Type;
             XPClassInfo typeInfo = dictionary.GetClassInfo(classType);
             lock (typeInfo) {
                 if (typeInfo.FindMember(modelRuntimeMember.Name) == null) {
                     XpandCustomMemberInfo memberInfo = GetMemberInfo(modelRuntimeMember, typeInfo);
                     AddAttributes(modelRuntimeMember, memberInfo);
                     XafTypesInfo.Instance.RefreshInfo(classType);
                 }
             }
         } catch (Exception exception) {
             throw new Exception(
                 ExceptionLocalizerTemplate<SystemExceptionResourceLocalizer, ExceptionId>.GetExceptionMessage(
                     ExceptionId.ErrorOccursWhileAddingTheCustomProperty,
                     modelRuntimeMember.MemberInfo.MemberType,
                     ((IModelClass)modelRuntimeMember.Parent).Name,
                     modelRuntimeMember.Name,
                     exception.Message));
         }
 }
Ejemplo n.º 12
0
        public static XPClassInfo AddClass(XPDictionary dict, DBTable table)
        {
            if (table.PrimaryKey.Columns.Count > 1)
            {
                throw new NotSupportedException("Compound primary keys are not supported");
            }
            XPClassInfo classInfo = dict.CreateClass(dict.GetClassInfo(typeof(BasePersistentClass)), table.Name.Replace('.', '_'));

            classInfo.AddAttribute(new PersistentAttribute(table.Name));
            DBColumnType primaryColumnType = table.GetColumn(table.PrimaryKey.Columns[0]).ColumnType;

            classInfo.CreateMember(table.PrimaryKey.Columns[0], DBColumn.GetType(primaryColumnType),
                                   new KeyAttribute(IsAutoGenerationSupported(primaryColumnType)));
            foreach (DBColumn col in table.Columns)
            {
                if (!col.IsKey && col.ColumnType != DBColumnType.Unknown)
                {
                    classInfo.CreateMember(col.Name, DBColumn.GetType(col.ColumnType));
                }
            }
            return(classInfo);
        }