public void Test_DefaultModelBuilder()
        {
            string uri = "SqlMap_Test_Configure.config";
            IConfigurationStore store = new DefaultConfigurationStore();

            IConfigurationInterpreter interpreter = new XmlConfigurationInterpreter(uri);

            interpreter.ProcessResource(store);
            //Console.WriteLine(store.ToString());

            IModelStore modelStore = new DefaultModelStore();
            IModelBuilder builder = new DefaultModelBuilder(modelStore);

            builder.BuildModel(null, store);

            CheckModelStore(modelStore);
        }
        /// <summary>
        /// Builds the mapper factory.
        /// </summary>
        /// <returns>the mapper factory</returns>
        public IMapperFactory BuildMapperFactory()
        {
            // Registers file Xml, ... configuration element
            if (interpreter != null)
            {
                interpreter.ProcessResource(configurationStore);

                // ensure that the default configuration settings get updated after the interpreter runs
                configurationSetting.PreserveWhitespace       = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace);
                configurationSetting.UseReflectionOptimizer   = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_REFLECTION_OPTIMIZER, configurationSetting.UseReflectionOptimizer);
                configurationSetting.IsCacheModelsEnabled     = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_CACHE_MODELS_ENABLED, configurationSetting.IsCacheModelsEnabled);
                configurationSetting.UseStatementNamespaces   = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_STATEMENT_NAMESPACES, configurationSetting.UseStatementNamespaces);
                configurationSetting.ValidateMapperConfigFile = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_VALIDATE_SQLMAP, configurationSetting.ValidateMapperConfigFile);
            }

            // Registers code configuration element
            for (int i = 0; i < modules.Count; i++)
            {
                modules[i].Configure(this);
            }

            // Process Extends ResultMap
            List <IConfiguration> resolved = new List <IConfiguration>();

            for (int i = 0; i < configurationStore.ResultMaps.Length; i++)
            {
                ResolveExtendResultMap(resolved, configurationStore.ResultMaps[i]);
            }

            // Process Extends ParameterMap
            resolved = new List <IConfiguration>();
            for (int i = 0; i < configurationStore.ParameterMaps.Length; i++)
            {
                ResolveExtendParameterMap(resolved, configurationStore.ParameterMaps[i]);
            }

            // Process Include Sql statement
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                ConfigurationCollection includes = configurationStore.Statements[i].Children.RecursiveFind(ConfigConstants.ELEMENT_INCLUDE);

                if (includes.Count > 0)
                {
                    ResolveIncludeStatement(includes);
                }
            }

            // Process Extends statement
            resolved = new List <IConfiguration>();
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                ResolveExtendStatement(resolved, configurationStore.Statements[i]);
            }

            modelStore = new DefaultModelStore();

            IModelBuilder builder = new DefaultModelBuilder(modelStore);

            builder.BuildModel(configurationSetting, configurationStore);

            IDataMapper dataMapper = new DataMapper(modelStore);

            return(new DefaultMapperFactory(dataMapper));
        }
        /// <summary>
        /// Builds the mapper factory.
        /// </summary>
        /// <returns>the mapper factory</returns>
        public IMapperFactory BuildMapperFactory()
        {
            // Registers file Xml, ... configuration element
            if (interpreter!=null)
            {
                interpreter.ProcessResource(configurationStore);

                // ensure that the default configuration settings get updated after the interpreter runs
                configurationSetting.PreserveWhitespace = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace);
                configurationSetting.UseReflectionOptimizer = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_REFLECTION_OPTIMIZER, configurationSetting.UseReflectionOptimizer);
                configurationSetting.IsCacheModelsEnabled = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_CACHE_MODELS_ENABLED, configurationSetting.IsCacheModelsEnabled);
                configurationSetting.UseStatementNamespaces = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_USE_STATEMENT_NAMESPACES, configurationSetting.UseStatementNamespaces);
                configurationSetting.ValidateMapperConfigFile = TryGetSettingBoolean(ConfigConstants.ATTRIBUTE_VALIDATE_SQLMAP, configurationSetting.ValidateMapperConfigFile);
            }

            // Registers code configuration element
            //此处还未有案例分析????
            for(int i=0;i<modules.Count;i++)
            {
                modules[i].Configure(this);
            }

            // Process Extends ResultMap
            //将父节点的子节点信息添加到含有extends节点的下面
            List<IConfiguration> resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.ResultMaps.Length; i++)
            {
                ResolveExtendResultMap(resolved, configurationStore.ResultMaps[i]);
            }

            // Process Extends ParameterMap
            resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.ParameterMaps.Length; i++)
            {
                ResolveExtendParameterMap(resolved, configurationStore.ParameterMaps[i]);
            }

            // Process Include Sql statement
            //处理statements节点下的include属性
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                //获取节点statement update insert delete select节点的子节点include集合
                ConfigurationCollection includes = configurationStore.Statements[i].Children.RecursiveFind(ConfigConstants.ELEMENT_INCLUDE);

                if (includes.Count > 0)
                {
                    ResolveIncludeStatement(includes);
                }
            }

            // Process Extends statement
            resolved = new List<IConfiguration>();
            for (int i = 0; i < configurationStore.Statements.Length; i++)
            {
                ResolveExtendStatement(resolved, configurationStore.Statements[i]);
            }

            modelStore = new DefaultModelStore();

            IModelBuilder builder = new DefaultModelBuilder(modelStore);
            //核心处理结果都存储在了modelStore类中了
            builder.BuildModel(configurationSetting, configurationStore);
            //将核心处理结果对象存到DataMapper类中
            IDataMapper dataMapper = new DataMapper(modelStore);

            return new DefaultMapperFactory(dataMapper);
        }