/// <summary> /// Deserializes the specified configuration in a <see cref="Procedure"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); if (parameterClass != null) { } else { if (parameterMap == null) { parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP); } } return(new Procedure( id, parameterClass, parameterMap, resultClass, resultsMap, listClass, listClassFactory, cacheModel, remapResults, string.Empty, sqlSource, preserveWhitespace)); }
/// <summary> /// Deserializes the specified configuration in a <see cref="Procedure"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); if (parameterClass!=null) { } else { if (parameterMap == null) { parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP); } } return new Procedure( id, parameterClass, parameterMap, resultClass, resultsMap, listClass, listClassFactory, cacheModel, remapResults, string.Empty, sqlSource, preserveWhitespace); }
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore"></param> /// <param name="config">The config.</param> /// <param name="configurationSetting">Default settings.</param> /// <returns></returns> protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE); id = configurationSetting.UseStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id; cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL); extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS); listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS); parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS); parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP); resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS); resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP); remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false); sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE); preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace); // Gets the results Map if (resultMapName.Length > 0) { string[] ids = resultMapName.Split(','); for (int i = 0; i < ids.Length; i++) { string name = ApplyNamespace(nameSpace, ids[i].Trim()); resultsMap.Add(modelStore.GetResultMap(name)); } } // Gets the results class if (resultClassName.Length > 0) { string[] classNames = resultClassName.Split(','); for (int i = 0; i < classNames.Length; i++) { resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim()); IFactory resultClassFactory = null; if (Type.GetTypeCode(resultClass) == TypeCode.Object && (resultClass.IsValueType == false) && resultClass != typeof(DataRow)) { resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes); } IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass); bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass); IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType); resultsMap.Add(autoMap); } } // Gets the ParameterMap if (parameterMapName.Length > 0) { parameterMap = modelStore.GetParameterMap(parameterMapName); } // Gets the ParameterClass if (parameterClassName.Length > 0) { parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName); } // Gets the listClass if (listClassName.Length > 0) { listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName); listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes); } // Gets the CacheModel if (cacheModelName.Length > 0) { cacheModel = modelStore.GetCacheModel(cacheModelName); } // Gets the SqlSource if (sqlSourceClassName.Length > 0) { Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName); IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes); sqlSource = (ISqlSource)factory.CreateInstance(null); } }
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore"></param> /// <param name="config">The config.</param> /// <param name="configurationSetting">Default settings.</param> /// <returns></returns> /// <remarks> /// Updated By: Richard Beacroft /// Updated Date: 11\10\2013 /// Description: configurationSetting can be null and therefore references to it have to assume that it could be null. /// </remarks> protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { // DefaultModelBuilderTest.Test_DefaultModelBuilder assumes that configurationSetting can be null - added code accordingly. // Typically, no public method should allow null to be passed-in, best handled by overloading method to exclude parameter, or in .NET 4, use optional parameter. var preserveWhitespace = (configurationSetting == null) ? false : configurationSetting.PreserveWhitespace; bool useStatementNamespaces = (configurationSetting == null) ? false : configurationSetting.UseStatementNamespaces; nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE); id = useStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id; cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL); extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS); listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS); parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS); parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP); resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS); resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP); remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false); sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE); preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, preserveWhitespace); // Gets the results Map if (resultMapName.Length > 0) { string[] ids = resultMapName.Split(','); for (int i = 0; i < ids.Length; i++) { string name = ApplyNamespace(nameSpace, ids[i].Trim()); resultsMap.Add(modelStore.GetResultMap(name)); } } // Gets the results class if (resultClassName.Length > 0) { string[] classNames = resultClassName.Split(','); for (int i = 0; i < classNames.Length; i++) { resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim()); IFactory resultClassFactory = null; if (Type.GetTypeCode(resultClass) == TypeCode.Object && (resultClass.IsValueType == false) && resultClass != typeof(DataRow)) { resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes); } IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass); bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass); IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType); resultsMap.Add(autoMap); } } // Gets the ParameterMap if (parameterMapName.Length > 0) { parameterMap = modelStore.GetParameterMap(parameterMapName); } // Gets the ParameterClass if (parameterClassName.Length > 0) { parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName); } // Gets the listClass if (listClassName.Length > 0) { listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName); listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes); } // Gets the CacheModel if (cacheModelName.Length > 0) { cacheModel = modelStore.GetCacheModel(cacheModelName); } // Gets the SqlSource if (sqlSourceClassName.Length > 0) { Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName); IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes); sqlSource = (ISqlSource)factory.CreateInstance(null); } }