Beispiel #1
0
        public static SchemaObjectBase CreateObject(string schemaTypeString)
        {
            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            ObjectSchemaConfigurationElement schemaElement = settings.Schemas[schemaTypeString];

            (schemaElement != null).FalseThrow <NotSupportedException>("不支持的对象类型: {0}", schemaTypeString);

            SchemaObjectBase result = null;

            if (schemaElement.GetTypeInfo() == typeof(SCGenericObject))
            {
                result = new SCGenericObject(schemaTypeString);
            }
            else
            {
                result = (SchemaObjectBase)schemaElement.CreateInstance(schemaTypeString);
                if (result.SchemaType != schemaTypeString)
                {
                    throw new SchemaObjectErrorCreationException(string.Format("无法根据指定的SchemaType {0} 创建对应的类型", schemaTypeString));
                }
            }

            return(result);
        }
Beispiel #2
0
        protected virtual void RenderInlineStyleSheet(HtmlTextWriter output)
        {
            output.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
            output.RenderBeginTag(HtmlTextWriterTag.Style);
            if ((this.Size & IconSize.Size16) == IconSize.Size16)
            {
                output.Write(".pc-icon16{ display:inline-block; width:16px; height:16px; border:0; padding:0; vertical-align: middle; }");
                foreach (ObjectSchemaConfigurationElement schema in ObjectSchemaSettings.GetConfig().Schemas)
                {
                    string key = schema.Name;
                    string img = MCS.Web.WebControls.ControlResources.GetResourceByKey(schema.LogoImage + "16");
                    output.Write(".pc-icon16." + key + "{");
                    output.Write("background: transparent url('{0}') scroll 0 0 ;", img);
                    output.Write("}\r\n");
                }
            }

            if ((this.Size & IconSize.Size32) == IconSize.Size32)
            {
                output.Write(".pc-icon32{ display:inline-block; width:32px; height:32px; border:0; padding:0; vertical-align: middle; }");
                foreach (ObjectSchemaConfigurationElement schema in ObjectSchemaSettings.GetConfig().Schemas)
                {
                    string key = schema.Name;
                    string img = MCS.Web.WebControls.ControlResources.GetResourceByKey(schema.LogoImage + "32");
                    output.Write(".pc-icon32." + key + "{");
                    output.Write("background: transparent url('{0}') scroll 0 0 ;", img);
                    output.Write("}\r\n");
                }
            }

            output.RenderEndTag();
        }
        private static bool IsSuperAdmin(IPrincipal principal)
        {
            return(DEPrincipalCache.Instance.GetOrAddNewValue(principal.Identity.Name, (cache, key) =>
            {
                bool innerResult = false;
                if (ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName.IsNotEmpty())
                {
                    IRole role = new OguRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);

                    if (role.ObjectsInRole.Count == 0)
                    {
                        innerResult = true;
                    }
                    else
                    {
                        innerResult = principal.IsInRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);
                    }
                }
                else
                {
                    innerResult = true;
                }

                cache.Add(key, innerResult);

                return innerResult;
            }));
        }
Beispiel #4
0
        private static SCAclPermissionItemCollection GetPermissionDefinitions(string schemaType)
        {
            var element          = ObjectSchemaSettings.GetConfig().Schemas[schemaType];
            var permissionDefine = new SCAclPermissionItemCollection(element.PermissionSet);

            return(permissionDefine);
        }
Beispiel #5
0
        private HashSet <string> GetCommonGroups(HashSet <string> schemaTypes)
        {
            HashSet <string> groupNames = new HashSet <string>();
            List <string>    tempNames  = new List <string>();

            // 提取所有的组
            foreach (string item in schemaTypes)
            {
                var schemaConfig = ObjectSchemaSettings.GetConfig().Schemas[item];
                foreach (ObjectSchemaClassConfigurationElement elem in schemaConfig.Groups)
                {
                    groupNames.Add(elem.GroupName);
                }
            }

            //保留公有的组
            foreach (string item in schemaTypes)
            {
                tempNames.Clear();
                var schemaConfig = ObjectSchemaSettings.GetConfig().Schemas[item];
                foreach (ObjectSchemaClassConfigurationElement elem in schemaConfig.Groups)
                {
                    tempNames.Add(elem.GroupName);
                }

                groupNames.IntersectWith(tempNames);
            }
            return(groupNames);
        }
        public void LoadFromDataReader(IDataReader reader)
        {
            Dictionary <string, ObjectSchemaConfigurationElement> schemaElements = new Dictionary <string, ObjectSchemaConfigurationElement>(StringComparer.OrdinalIgnoreCase);

            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            while (reader.Read())
            {
                string schemaType = (string)reader["SchemaType"];
                ObjectSchemaConfigurationElement schemaElement = null;

                if (schemaElements.TryGetValue(schemaType, out schemaElement) == false)
                {
                    schemaElement = settings.Schemas[schemaType];

                    schemaElements.Add(schemaType, schemaElement);
                }

                if (schemaElement != null)
                {
                    T obj = (T)schemaElement.CreateInstance(schemaType);

                    obj.FromString((string)reader["Data"]);

                    ORMapping.DataReaderToObject(reader, obj);

                    if (this.ContainsKey(obj.ID) == false)
                    {
                        this.Add(obj);
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 根据schemaType构造DESchemaDefine
        /// </summary>
        /// <param name="schemaType"></param>
        /// <returns></returns>
        public static DESchemaDefine Create(string schemaType)
        {
            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            settings.Schemas.ContainsKey(schemaType).FalseThrow("不能找到{0}的SchemaType的定义", schemaType);

            return(new DESchemaDefine(settings.Schemas[schemaType]));
        }
Beispiel #8
0
        public void LoadSchemaInfo()
        {
            SchemaInfoCollection sic = new SchemaInfoCollection(ObjectSchemaSettings.GetConfig().Schemas);

            SchemaInfoCollection usersInfo = sic.FilterByCategory("Users");

            Assert.IsTrue(usersInfo.Count > 0);
        }
Beispiel #9
0
        public void LoadObjectSchemas()
        {
            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            SchemaDefineCollection schemas = new SchemaDefineCollection(settings.Schemas);

            schemas.ForEach(s => s.Output(Console.Out));
        }
Beispiel #10
0
        public void LoadObjectSchemasSettings()
        {
            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            foreach (ObjectSchemaConfigurationElement schema in settings.Schemas)
            {
                schema.Output(Console.Out);
            }
        }
Beispiel #11
0
        /*
         *      internal static void ValidateAdminRole(MCS.Library.OGUPermission.IRole role)
         *      {
         *              string[] parts = role.FullCodeName.Split(':');
         *
         *              if (parts.Length != 2 || parts[0].Length == 0 || parts[1].Length == 0)
         *                      throw new FormatException("角色的全名格式有误");
         *
         *              var app = PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Applications", parts[0], DateTime.MinValue) as PC.SCApplication;
         *
         *              var role1 = PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Roles", parts[1], DateTime.MinValue) as PC.SCRole;
         *
         *              if (app == null)
         *                      throw new ManageRoleNotExistException(parts[0], parts[1]);
         *
         *              if (PC.Adapters.SCMemberRelationAdapter.Instance.Load(app.ID, role1.ID) == null)
         *                      throw new ManageRoleNotExistException(parts[0], parts[1], string.Format("存在无效的配置,指定的角色全名对应无效的对象{0}", parts[0], parts[1]));
         *      }
         */

        internal static ManageAclStatus GetAdminRoleStatus(BannerNotice notice)
        {
            ManageAclStatus result;

            var adminRole = ObjectSchemaSettings.GetConfig().GetAdminRole();

            if (adminRole != null)
            {
                // 检查授权
                try
                {
                    // Util.ValidateAdminRole(adminRole);
                    // 经过这步,基本确定配置和当前对象无误
                    string[] parts = adminRole.FullCodeName.Split(':');

                    string adminRoleID;
                    if (parts.Length != 2)
                    {
                        throw new FormatException("配置文件中的管理角色路径格式错误。");
                    }

                    try
                    {
                        adminRoleID = adminRole.ID; // 有可能抛异常
                    }
                    catch (Exception ex)
                    {
                        throw new ManageRoleNotExistException(parts[0], parts[1], ex);
                    }

                    if (Util.IsRoleEmpty(adminRoleID))
                    {
                        notice.Text       = string.Format("管理角色{0}尚无任何人员,权限已完全开放,请联系管理员立即处理此安全风险。", adminRole.FullCodeName);
                        notice.RenderType = WebControls.NoticeType.Warning;
                        result            = ManageAclStatus.NobodyIn;
                    }
                    else
                    {
                        result = ManageAclStatus.Ready;
                    }
                }
                catch (ManageRoleNotExistException m)
                {
                    notice.Text       = m.Message + " 请联系管理员";
                    notice.RenderType = WebControls.NoticeType.Error;
                    result            = ManageAclStatus.RoleNotExists;
                }
            }
            else
            {
                notice.RenderType = WebControls.NoticeType.Error;
                notice.Text       = "系统尚未配置管理应用和角色,授权管理操作对所有用户开放,为了防范安全风险请联系管理员立即修改配置并重启服务。";
                result            = ManageAclStatus.NoConfig;
            }

            return(result);
        }
Beispiel #12
0
        public void LoadBaseObjectSchemaInfo()
        {
            SchemaInfoCollection sic = new SchemaInfoCollection(ObjectSchemaSettings.GetConfig().Schemas);

            SchemaInfoCollection schemasInfo = sic.FilterByNotRelation();

            schemasInfo.ForEach(s => s.Output(Console.Out));

            Assert.IsTrue(schemasInfo.Count > 0);
        }
 internal static IEnumerable <string> GetScopeSchemas(string codeNameKey)
 {
     foreach (ObjectSchemaConfigurationElement schemaElem in ObjectSchemaSettings.GetConfig().Schemas)
     {
         if (schemaElem.CodeNameKey == codeNameKey)
         {
             yield return(schemaElem.Name);
         }
     }
 }
Beispiel #14
0
        private void CodeNameValidationMethod(string strToValue, SchemaObjectBase doValidateObj, string key, ValidationResults validateResults)
        {
            bool result = CodeNameUniqueValidatorFacade.ValidateCodeName(strToValue, CodeNameUniqueValidatorFacade.GetScopeSchemas2(doValidateObj.Schema.CodeNameKey).ToArray(), doValidateObj.ID, this.includingDeleted == false, false, DateTime.MinValue);

            if (result == false)
            {
                ObjectSchemaConfigurationElement config = ObjectSchemaSettings.GetConfig().Schemas[doValidateObj.SchemaType];
                RecordValidationResult(validateResults, string.Format(this.MessageTemplate, string.IsNullOrEmpty(config.Description) ? config.Description : config.Name, doValidateObj.Properties["Name"].StringValue, doValidateObj.ID), doValidateObj, key);
            }
        }
        /// <summary>
        /// 是否是超级管理员
        /// </summary>
        /// <param name="principal"></param>
        /// <returns></returns>
        public static bool IsSupervisor(this IPrincipal principal)
        {
            bool result = false;

            //Modified by Haoyk
            //2015-02-02
            //动态实体项目单设管理员
            if (principal != null)
            {
                result = DEPrincipalCache.Instance.GetOrAddNewValue(principal.Identity.Name, (cache, key) =>
                {
                    bool innerResult = false;

                    if (ConfigurationManager.AppSettings["DEAdmin"] != null && ConfigurationManager.AppSettings["DEAdmin"].IsNotEmpty())
                    {
                        string roleStr = ConfigurationManager.AppSettings["DEAdmin"].Trim();

                        if (string.IsNullOrEmpty(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName))
                        {
                            innerResult = true;
                        }
                        else
                        {
                            IRole role = new OguRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);
                            if (role.ObjectsInRole.Count == 0)
                            {
                                innerResult = true;
                            }
                            else
                            {
                                innerResult = principal.IsInRole(roleStr);
                            }

                            //如果不属于DEAdmin,则进一步判断是否是超级管理员
                            if (innerResult == false)
                            {
                                innerResult = IsSuperAdmin(principal);
                            }
                        }
                    }
                    else
                    {
                        //如果没有配置则都认为人人都是管理员
                        innerResult = true;
                    }

                    cache.Add(key, innerResult);
                    return(innerResult);
                });
            }

            return(result);
        }
Beispiel #16
0
        protected override void OnPreRender(EventArgs e)
        {
            this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            if (this.IsPostBack == false && this.IsCallback == false)
            {
                this.RenderAllTabs(this.Data, this.EditEnabled == false || this.Data.Status != SchemaObjectStatus.Normal);
            }

            base.OnPreRender(e);

            this.description.InnerText  = ObjectSchemaSettings.GetConfig().Schemas[this.Data.SchemaType].Description;
            this.lblCurrentID.InnerText = this.Data != null ? this.Data.ID : "(空)";
        }
Beispiel #17
0
        protected string SchemaTypeToString(string schemaName)
        {
            string result = schemaName;

            ObjectSchemaConfigurationElement schemaElement = ObjectSchemaSettings.GetConfig().Schemas[schemaName];

            if (schemaElement != null && schemaElement.Description.IsNotEmpty())
            {
                result = schemaElement.Description;
            }

            return(result);
        }
        public SchemaObjectBase XmlToObject(string xml, string schemaType)
        {
            if (this.config == null)
            {
                this.config = ObjectSchemaSettings.GetConfig();
            }

            var obj = (SchemaObjectBase)this.config.Schemas[schemaType].CreateInstance(schemaType);

            obj.FromString(xml);

            return(obj);
        }
        public static bool Validate(string codeName, string objectID, string objectSchemaType, string parentID, bool normalOnly, bool ignoreVersions, DateTime timePoint)
        {
            var schemaConfig = ObjectSchemaSettings.GetConfig().Schemas[objectSchemaType];
            IEnumerable <string> schemaNames = GetScopeSchemas(schemaConfig.CodeNameKey);

            switch (schemaConfig.CodeNameValidationMethod)
            {
            case SchemaObjectCodeNameValidationMethod.ByCodeNameKey:
                return(ValidateCodeName(codeName, schemaNames.ToArray(), objectID, normalOnly, ignoreVersions, timePoint));

            case SchemaObjectCodeNameValidationMethod.ByContainerAndCodeNameKey:
                return(ValidateCodeNameWithContainer(codeName, schemaNames.ToArray(), objectID, parentID, normalOnly, ignoreVersions, timePoint));

            default:
                throw new NotSupportedException("不支持的验证方式");
            }
        }
Beispiel #20
0
        private void RenderTabs(HashSet <string> schemaTypes, SchemaPropertyValueCollection propertyValues, HashSet <string> tabNames)
        {
            if (tabNames.Count > 0)
            {
                var tabs = ObjectSchemaSettings.GetConfig().Schemas[schemaTypes.First()].Tabs;
                foreach (string item in tabNames)
                {
                    RelaxedTabPage tabPage = new RelaxedTabPage()
                    {
                        Title  = tabs[item].Description,
                        TagKey = item
                    };

                    this.tabs.TabPages.Add(tabPage);

                    PropertyForm pForm = new PropertyForm()
                    {
                        AutoSaveClientState = false
                    };
                    pForm.ID       = tabPage.TagKey + "_Form";
                    pForm.ReadOnly = this.EditEnabled == false;

                    //// if (currentScene.Items[this.tabStrip.ID].Recursive == true)
                    ////    pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly;

                    var pageValues = TabGroup(propertyValues, item).ToPropertyValues();
                    pForm.Properties.CopyFrom(pageValues);
                    pForm.ShowCheckBoxes = true;

                    PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection();
                    layouts.LoadLayoutSectionFromConfiguration("DefalutLayout");

                    pForm.Layouts.InitFromLayoutSectionCollection(layouts);

                    pForm.Style["width"]  = "100%";
                    pForm.Style["height"] = "400";

                    tabPage.Controls.Add(pForm);
                }

                this.tabs.ActiveTabPageIndex = 0;
            }
        }
        protected override void OnBuildQueryCondition(QueryCondition qc)
        {
            qc.FromClause   = TimePointContext.Current.UseCurrentTime ? "SC.SchemaObjectSnapshot_Current O INNER JOIN SC.SchemaRelationObjectsSnapshot_Current R ON O.ID = R.ObjectID" : "SC.SchemaObjectSnapshot O INNER JOIN SC.SchemaRelationObjectsSnapshot R ON O.ID = R.ObjectID";
            qc.SelectFields = "O.*,R.ParentID,R.FullPath";
            if (string.IsNullOrEmpty(qc.OrderByClause))
            {
                qc.OrderByClause = "R.InnerSort ASC";
            }

            qc.WhereClause.IsNotEmpty((s) => qc.WhereClause += " AND ");
            InSqlClauseBuilder inSql = new InSqlClauseBuilder("O.SchemaType");

            if (this.schemaTypes != null && this.schemaTypes.Length > 0)
            {
                inSql.AppendItem(this.schemaTypes);
            }
            else
            {
                var config = ObjectSchemaSettings.GetConfig();
                inSql.AppendItem(SchemaInfo.FilterByCategory("Users", "Groups", "Organizations").ToSchemaNames());
                if (inSql.IsEmpty)
                {
                    throw new ApplicationException("配置中不存在任何可用的Schema");
                }
            }

            var timeCondition1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("R.");

            var where = new WhereSqlClauseBuilder();
            where.AppendItem("R.Status", (int)SchemaObjectStatus.Normal);
            where.AppendItem("R.ParentSchemaType", "Organizations");

            if (startPath.IsNotEmpty())
            {
                where.AppendItem("R.FullPath", TSqlBuilder.Instance.EscapeLikeString(startPath) + "%", "LIKE");
            }

            var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("O.");

            where.AppendItem("O.Status", (int)SchemaObjectStatus.Normal);

            qc.WhereClause += new ConnectiveSqlClauseCollection(timeCondition1, timeCondition2, where, inSql).ToSqlString(TSqlBuilder.Instance);
        }
Beispiel #22
0
        protected override void DoValidate(object objectToValidate, object currentObject, string key, Validation.ValidationResults validateResults)
        {
            DESchemaObjectBase doValidateObj = currentObject as DESchemaObjectBase;

            if (doValidateObj != null)
            {
                string strValue = objectToValidate.ToString();

                if (strValue.IsNotEmpty())
                {
                    bool exist = DEDynamicEntityAdapter.Instance.ExistByCodeName(strValue, DateTime.MinValue);
                    //不存在
                    if (exist == false)
                    {
                        ObjectSchemaConfigurationElement config = ObjectSchemaSettings.GetConfig().Schemas[doValidateObj.SchemaType];
                        RecordValidationResult(validateResults, string.Format(this.MessageTemplate, string.IsNullOrEmpty(config.Description) ? config.Description : config.Name, doValidateObj.Properties["Name"].StringValue, doValidateObj.ID), doValidateObj, key);
                    }
                }
            }
        }
Beispiel #23
0
        public void AclPermissionsDefineTest()
        {
            ObjectSchemaConfigurationElement element = ObjectSchemaSettings.GetConfig().Schemas["Applications"];

            Assert.IsNotNull(element);

            SCAclPermissionItemCollection permissionDefine = new SCAclPermissionItemCollection(element.PermissionSet);

            Console.WriteLine("Application permissions:");
            permissionDefine.ForEach(pd => pd.Output(Console.Out));

            element = ObjectSchemaSettings.GetConfig().Schemas["Organizations"];

            Assert.IsNotNull(element);

            permissionDefine = new SCAclPermissionItemCollection(element.PermissionSet);

            Console.WriteLine("Organization permissions:");
            permissionDefine.ForEach(pd => pd.Output(Console.Out));
        }
Beispiel #24
0
        /// <summary>
        /// 根据模式类型,条件和时间点载入视图
        /// </summary>
        /// <param name="schemaType">模式类型</param>
        /// <param name="inBuilder">条件</param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public DataView Load(string schemaType, IConnectiveSqlClause inBuilder, DateTime timePoint)
        {
            ObjectSchemaConfigurationElement schemaElem = ObjectSchemaSettings.GetConfig().Schemas[schemaType];

            (schemaElem != null).FalseThrow("不能找到SchemaType为{0}的定义", schemaType);

            var whereBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(inBuilder, whereBuilder);

            DataView result = null;

            VersionedObjectAdapterHelper.Instance.FillData(schemaElem.SnapshotTable, connectiveBuilder, this.GetConnectionName(),
                                                           view =>
            {
                result = view;
            });

            return(result);
        }
Beispiel #25
0
        public void GetSchemaPerformanceTest()
        {
            var schemaElem = ObjectSchemaSettings.GetConfig().Schemas[0];

            Stopwatch sw = new Stopwatch();

            sw.Start();
            try
            {
                for (int i = 0; i < 100000; i++)
                {
                    SchemaDefine schema = SchemaDefine.GetSchema(schemaElem.Name);
                }
            }
            finally
            {
                sw.Stop();

                Console.WriteLine("经过时间{0:#,##0}毫秒", sw.ElapsedMilliseconds);
            }
        }
Beispiel #26
0
        public static DESchemaObjectBase CreateObject(string schemaTypeString)
        {
            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            ObjectSchemaConfigurationElement schemaElement = settings.Schemas[schemaTypeString];

            (schemaElement != null).FalseThrow <NotSupportedException>("不支持的对象类型: {0}", schemaTypeString);

            DESchemaObjectBase result = null;

            if (schemaElement.GetTypeInfo() == typeof(DEGenericObject))
            {
                result = new DEGenericObject(schemaTypeString);
            }
            else
            {
                result = (DESchemaObjectBase)schemaElement.CreateInstance();
            }

            return(result);
        }
Beispiel #27
0
        protected override void DoValidate(object objectToValidate, object currentObject, string key, ValidationResults validateResults)
        {
            bool isValid = false;
            var  types   = SchemaInfo.FilterByCategory("AdminScopeItems");

            foreach (var item in types)
            {
                if (item.Name.Equals(objectToValidate))
                {
                    isValid = true;
                    break;
                }
            }

            if (isValid == false)
            {
                SchemaObjectBase doValidateObj          = (SchemaObjectBase)currentObject;
                ObjectSchemaConfigurationElement config = ObjectSchemaSettings.GetConfig().Schemas[doValidateObj.SchemaType];
                this.RecordValidationResult(validateResults, string.Format(this.MessageTemplate, string.IsNullOrEmpty(config.Description) ? config.Description : config.Name, doValidateObj.Properties["Name"].StringValue, doValidateObj.ID), doValidateObj, key);
            }
        }
Beispiel #28
0
        public void CreateSchemaObjectPerformanceTest()
        {
            var schemaElem = ObjectSchemaSettings.GetConfig().Schemas[0];

            Stopwatch sw = new Stopwatch();

            sw.Start();
            try
            {
                for (int i = 0; i < 100000; i++)
                {
                    SchemaObjectBase obj = SchemaExtensions.CreateObject(schemaElem.Name);
                    Assert.IsTrue(obj.Properties != null);
                }
            }
            finally
            {
                sw.Stop();

                Console.WriteLine("经过时间{0:#,##0}毫秒", sw.ElapsedMilliseconds);
            }
        }
Beispiel #29
0
        public static System.Collections.Specialized.HybridDictionary GetSchemaCatgoryDictionary()
        {
            System.Collections.Specialized.HybridDictionary dic = null;

            if (HttpContext.Current.Items.Contains(Util.TheDicKey) == false)
            {
                dic = new System.Collections.Specialized.HybridDictionary();

                foreach (ObjectSchemaConfigurationElement schema in ObjectSchemaSettings.GetConfig().Schemas)
                {
                    dic.Add(schema.Name, schema.Category);
                }

                HttpContext.Current.Items.Add(Util.TheDicKey, dic);
            }
            else
            {
                dic = (System.Collections.Specialized.HybridDictionary)HttpContext.Current.Items[Util.TheDicKey];
            }

            return(dic);
        }
        public void LoadFromDataView(DataView view, Action <DataRow, T> action)
        {
            Dictionary <string, ObjectSchemaConfigurationElement> schemaElements = new Dictionary <string, ObjectSchemaConfigurationElement>(StringComparer.OrdinalIgnoreCase);

            ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig();

            foreach (DataRowView drv in view)
            {
                string schemaType = (string)drv["SchemaType"];

                ObjectSchemaConfigurationElement schemaElement = null;

                if (schemaElements.TryGetValue(schemaType, out schemaElement) == false)
                {
                    schemaElement = settings.Schemas[schemaType];

                    schemaElements.Add(schemaType, schemaElement);
                }

                if (schemaElement != null)
                {
                    T obj = (T)schemaElement.CreateInstance(schemaType);

                    obj.FromString((string)drv["Data"]);

                    ORMapping.DataRowToObject(drv.Row, obj);

                    if (action != null)
                    {
                        action(drv.Row, obj);
                    }

                    if (this.ContainsKey(obj.ID) == false)
                    {
                        this.Add(obj);
                    }
                }
            }
        }