/// <summary>
        /// Builds the cache model.
        /// </summary>
        /// <param name="store">The store.</param>
        private void BuildCacheModels(IConfigurationStore store)
        {
            for (int i = 0; i < store.CacheModels.Length; i++)
            {
                IConfiguration cacheModelConfig = store.CacheModels[i];
                CacheModel     cacheModel       = CacheModelDeSerializer.Deserialize(cacheModelConfig, modelStore.DataExchangeFactory);

                string nameSpace = ConfigurationUtils.GetMandatoryStringAttribute(cacheModelConfig, ConfigConstants.ATTRIBUTE_NAMESPACE);

                // Gets all the flush on excecute statement id
                ConfigurationCollection flushConfigs = cacheModelConfig.Children.Find(ConfigConstants.ELEMENT_FLUSHONEXECUTE);
                for (int j = 0; j < flushConfigs.Count; j++)
                {
                    string statementId = flushConfigs[j].Attributes[ConfigConstants.ATTRIBUTE_STATEMENT];
                    if (useStatementNamespaces)
                    {
                        statementId = ApplyNamespace(nameSpace, statementId);
                    }

                    cacheModel.StatementFlushNames.Add(statementId);
                }

                modelStore.AddCacheModel(cacheModel);
            }
        }
Exemple #2
0
        /// <summary>
        /// Builds the cache model.
        /// </summary>
        /// <param name="store">The store.</param>
        private void BuildCacheModels(IConfigurationStore store)
        {
            /*<cacheModels>节点信息格式
             * <cacheModels>
             *             <cacheModel id="account-cache" type="Perpetual" flushInterval="30" >
             *                    <flushOnExecute  statement="UpdateAccountViaInlineParameters"/>
             *                   <flushOnExecute  statement="UpdateAccountViaParameterMap"/>
             *           </cacheModel>
             * <cacheModels>
             */

            //store.CacheModels中存储的是cacheModel节点的类对象
            for (int i = 0; i < store.CacheModels.Length; i++)
            {
                IConfiguration cacheModelConfig = store.CacheModels[i];
                //cacheModel节点属性保存到类对象中
                CacheModel cacheModel = CacheModelDeSerializer.Deserialize(cacheModelConfig, modelStore.DataExchangeFactory);

                string nameSpace = ConfigurationUtils.GetMandatoryStringAttribute(cacheModelConfig, ConfigConstants.ATTRIBUTE_NAMESPACE);

                // Gets all the flush on excecute statement id
                //获取当前CacheModel节点flushOnExecute子节点
                ConfigurationCollection flushConfigs = cacheModelConfig.Children.Find(ConfigConstants.ELEMENT_FLUSHONEXECUTE);
                for (int j = 0; j < flushConfigs.Count; j++)
                {
                    //获取flushOnExecute子节点的statement对应的值
                    string statementId = flushConfigs[j].Attributes[ConfigConstants.ATTRIBUTE_STATEMENT];
                    if (useStatementNamespaces)//使用命名空间
                    {
                        statementId = ApplyNamespace(nameSpace, statementId);
                    }

                    //将处理后的statementId名称加入cacheModel的列表中  即cacheModel中包含了其子statement集合名称
                    cacheModel.StatementFlushNames.Add(statementId);
                }
                //将当前cacheModel加入到modelStore中的CacheModel字典中
                modelStore.AddCacheModel(cacheModel);
            }
        }