Example #1
0
        /// <summary>
        /// Получение определения типа метаданных по типу объекта.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public MetadataTypeDefinition GetTypeDefinition(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            this.Logger.WriteFormatMessage("Получение определения типа '{0}'", type.Name);

            MetadataTypeDefinition typeDefinition = null;
            string typeKey = type.AssemblyQualifiedName;

            if (!MetadataTypeProvider.TypeDefinitions.ContainsKey(typeKey))
            {
                if (!MetadataTypeProvider.Lockers.ContainsKey(typeKey))
                {
                    lock (MetadataTypeProvider.Locker)
                    {
                        if (!MetadataTypeProvider.Lockers.ContainsKey(typeKey))
                        {
                            MetadataTypeProvider.Lockers.Add(typeKey, new object());
                        }
                    }
                }

                lock (MetadataTypeProvider.Lockers[typeKey])
                {
                    if (!MetadataTypeProvider.TypeDefinitions.ContainsKey(typeKey))
                    {
                        this.Logger.WriteFormatMessage("Вызов конструктора определения типа '{0}'", type.Name);

                        typeDefinition = new MetadataTypeDefinition(type);
                        lock (MetadataTypeProvider.Locker)
                        {
                            MetadataTypeProvider.TypeDefinitions.Add(typeKey, typeDefinition);
                        }
                    }
                    else
                    {
                        typeDefinition = MetadataTypeProvider.TypeDefinitions[typeKey];
                    }
                }
            }
            else
            {
                typeDefinition = MetadataTypeProvider.TypeDefinitions[typeKey];
            }

            this.Logger.WriteFormatMessage("Получение определения типа '{0}' завершено.", type.Name);

            if (typeDefinition == null)
            {
                throw new Exception(string.Format("Не удалось получить определение типа метаданных {0}.", type.FullName));
            }

            return(typeDefinition);
        }
        /// <summary>
        /// К-тор.
        /// </summary>
        /// <param name="relativeName">Суффикс имени индекса.</param>
        /// <param name="classDefinition">Определение класса.</param>
        internal MetadataIndexDefinition(string relativeName, MetadataTypeDefinition classDefinition)
        {
            if (string.IsNullOrEmpty(relativeName))
            {
                throw new ArgumentNullException("relativeName");
            }
            if (classDefinition == null)
            {
                throw new Exception("classDefinition");
            }

            this.RelativeName    = relativeName;
            this.ClassDefinition = classDefinition;
        }
Example #3
0
        /// <summary>
        /// К-тор.
        /// </summary>
        /// <param name="table">Таблица метаданных.</param>
        /// <param name="typeDefinition">Определение типа метаданных.</param>
        public MetadataQueryBuilder(DBTable table, MetadataTypeDefinition typeDefinition)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (typeDefinition == null)
            {
                throw new ArgumentNullException("typeDefinition");
            }

            this.Table          = table;
            this.TypeDefinition = typeDefinition;
        }
        public DBObjectTableSchemaAdapter(MetadataTypeDefinition classDefinition, MetadataAdapter schemaAdapter)
        {
            if (classDefinition == null)
            {
                throw new ArgumentNullException("classDefinition");
            }

            if (schemaAdapter == null)
            {
                throw new ArgumentNullException("schemaAdapter");
            }

            this.ClassDefinition = classDefinition;
            this.SchemaAdapter   = schemaAdapter;
        }