/// <summary> /// Deserialize a CacheModel object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static CacheModel Deserialize(XmlNode node, ConfigurationScope configScope) { CacheModel model = new CacheModel(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); model.Id = NodeUtils.GetStringAttribute(prop, "id"); model.Implementation = NodeUtils.GetStringAttribute(prop, "implementation"); model.Implementation = configScope.SqlMapper.TypeHandlerFactory.GetTypeAlias(model.Implementation).Class.AssemblyQualifiedName; model.IsReadOnly = NodeUtils.GetBooleanAttribute(prop, "readOnly", true); model.IsSerializable = NodeUtils.GetBooleanAttribute(prop, "serialize", false); int count = node.ChildNodes.Count; for(int i=0;i<count;i++) { if (node.ChildNodes[i].LocalName=="flushInterval") { FlushInterval flush = new FlushInterval(); NameValueCollection props = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties); flush.Hours = NodeUtils.GetIntAttribute(props, "hours", 0); flush.Milliseconds = NodeUtils.GetIntAttribute(props, "milliseconds", 0); flush.Minutes = NodeUtils.GetIntAttribute(props, "minutes", 0); flush.Seconds = NodeUtils.GetIntAttribute(props, "seconds", 0); model.FlushInterval = flush; } } return model; }
/// <summary> /// Deserialize a Procedure object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static Select Deserialize(XmlNode node, ConfigurationScope configScope) { Select select = new Select(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); select.CacheModelName = NodeUtils.GetStringAttribute(prop, "cacheModel"); select.ExtendStatement = NodeUtils.GetStringAttribute(prop, "extends"); select.Id = NodeUtils.GetStringAttribute(prop, "id"); select.ListClassName = NodeUtils.GetStringAttribute(prop, "listClass"); select.ParameterClassName = NodeUtils.GetStringAttribute(prop, "parameterClass"); select.ParameterMapName = NodeUtils.GetStringAttribute(prop, "parameterMap"); select.ResultClassName = NodeUtils.GetStringAttribute(prop, "resultClass"); select.ResultMapName = NodeUtils.GetStringAttribute(prop, "resultMap"); select.AllowRemapping = NodeUtils.GetBooleanAttribute(prop, "remapResults", false); int count = node.ChildNodes.Count; for(int i=0;i<count;i++) { if (node.ChildNodes[i].LocalName=="generate") { Generate generate = new Generate(); NameValueCollection props = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties); generate.By = NodeUtils.GetStringAttribute(props, "by"); generate.Table = NodeUtils.GetStringAttribute(props, "table"); select.Generate = generate; } } return select; }
/// <summary> /// Initializes a new instance of the <see cref="DynamicSql"/> class. /// </summary> /// <param name="configScope">The config scope.</param> /// <param name="statement">The statement.</param> internal DynamicSql(ConfigurationScope configScope, IStatement statement) { _statement = statement; _usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters; _dataExchangeFactory = configScope.DataExchangeFactory; }
/// <summary> /// Deserialize a ResultMap object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static SubMap Deserialize(XmlNode node, ConfigurationScope configScope) { NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); string discriminatorValue = NodeUtils.GetStringAttribute(prop, "value"); string resultMapName = configScope.ApplyNamespace(NodeUtils.GetStringAttribute(prop, "resultMapping")); return new SubMap(discriminatorValue, resultMapName); }
/// <summary> /// Deserialize a ResultMap object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static ResultMap Deserialize(XmlNode node, ConfigurationScope configScope) { NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); ResultMap resultMap = new ResultMap(configScope, prop["id"], prop["class"], prop["extends"], prop["groupBy"]); configScope.ErrorContext.MoreInfo = "initialize ResultMap"; resultMap.Initialize( configScope ); return resultMap; }
/// <summary> /// Deserialize a ResultMap object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static Discriminator Deserialize(XmlNode node, ConfigurationScope configScope) { Discriminator discriminator = new Discriminator(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); discriminator.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler"); discriminator.CLRType = NodeUtils.GetStringAttribute(prop, "type"); discriminator.ColumnIndex = NodeUtils.GetIntAttribute( prop, "columnIndex", ResultProperty.UNKNOWN_COLUMN_INDEX ); discriminator.ColumnName = NodeUtils.GetStringAttribute(prop, "column"); discriminator.DbType = NodeUtils.GetStringAttribute(prop, "dbType"); discriminator.NullValue = prop["nullValue"]; return discriminator; }
/// <summary> /// Deserialize a Procedure object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static Procedure Deserialize(XmlNode node, ConfigurationScope configScope) { Procedure procedure = new Procedure(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); procedure.CacheModelName = NodeUtils.GetStringAttribute(prop, "cacheModel"); procedure.Id = NodeUtils.GetStringAttribute(prop, "id"); procedure.ListClassName = NodeUtils.GetStringAttribute(prop, "listClass"); procedure.ParameterMapName = NodeUtils.GetStringAttribute(prop, "parameterMap"); procedure.ResultClassName = NodeUtils.GetStringAttribute(prop, "resultClass"); procedure.ResultMapName = NodeUtils.GetStringAttribute(prop, "resultMap"); procedure.ListClassName = NodeUtils.GetStringAttribute(prop, "listClass"); return procedure; }
/// <summary> /// Deserialize a TypeAlias object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static void Deserialize(XmlNode node, ConfigurationScope configScope) { TypeAlias typeAlias = new TypeAlias(); configScope.ErrorContext.MoreInfo = "loading type alias"; NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); typeAlias.Name = NodeUtils.GetStringAttribute(prop,"alias"); typeAlias.ClassName = NodeUtils.GetStringAttribute(prop, "type"); configScope.ErrorContext.ObjectId = typeAlias.ClassName; configScope.ErrorContext.MoreInfo = "initialize type alias"; typeAlias.Initialize(); configScope.SqlMapper.TypeHandlerFactory.AddTypeAlias( typeAlias.Name, typeAlias ); }
/// <summary> /// Deserialize a ResultProperty object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static ArgumentProperty Deserialize(XmlNode node, ConfigurationScope configScope) { ArgumentProperty argumentProperty = new ArgumentProperty(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); argumentProperty.CLRType = NodeUtils.GetStringAttribute(prop, "type"); argumentProperty.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler"); argumentProperty.ColumnIndex = NodeUtils.GetIntAttribute( prop, "columnIndex", ResultProperty.UNKNOWN_COLUMN_INDEX ); argumentProperty.ColumnName = NodeUtils.GetStringAttribute(prop, "column"); argumentProperty.DbType = NodeUtils.GetStringAttribute(prop, "dbType"); argumentProperty.NestedResultMapName = NodeUtils.GetStringAttribute(prop, "resultMapping"); argumentProperty.NullValue = prop["nullValue"]; argumentProperty.ArgumentName = NodeUtils.GetStringAttribute(prop, "argumentName"); argumentProperty.Select = NodeUtils.GetStringAttribute(prop, "select"); return argumentProperty; }
/// <summary> /// Deserialize a Procedure object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static Statement Deserialize(XmlNode node, ConfigurationScope configScope) { Statement statement = new Statement(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); statement.CacheModelName = NodeUtils.GetStringAttribute(prop, "cacheModel"); statement.ExtendStatement = NodeUtils.GetStringAttribute(prop, "extends"); statement.Id = NodeUtils.GetStringAttribute(prop, "id"); statement.ListClassName = NodeUtils.GetStringAttribute(prop, "listClass"); statement.ParameterClassName = NodeUtils.GetStringAttribute(prop, "parameterClass"); statement.ParameterMapName = NodeUtils.GetStringAttribute(prop, "parameterMap"); statement.ResultClassName = NodeUtils.GetStringAttribute(prop, "resultClass"); statement.ResultMapName = NodeUtils.GetStringAttribute(prop, "resultMap"); statement.AllowRemapping = NodeUtils.GetBooleanAttribute(prop, "remapResults", false); return statement; }
/// <summary> /// Deserialize a ResultProperty object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static ResultProperty Deserialize(XmlNode node, ConfigurationScope configScope) { ResultProperty resultProperty = new ResultProperty(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); resultProperty.CLRType = NodeUtils.GetStringAttribute(prop, "type"); resultProperty.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler"); resultProperty.ColumnIndex = NodeUtils.GetIntAttribute( prop, "columnIndex", ResultProperty.UNKNOWN_COLUMN_INDEX ); resultProperty.ColumnName = NodeUtils.GetStringAttribute(prop, "column"); resultProperty.DbType = NodeUtils.GetStringAttribute(prop, "dbType"); resultProperty.IsLazyLoad = NodeUtils.GetBooleanAttribute( prop, "lazyLoad", false); resultProperty.NestedResultMapName = NodeUtils.GetStringAttribute(prop, "resultMapping"); resultProperty.NullValue = prop["nullValue"]; resultProperty.PropertyName = NodeUtils.GetStringAttribute(prop, "property"); resultProperty.Select = NodeUtils.GetStringAttribute(prop, "select"); return resultProperty; }
/// <summary> /// Deserialize a sql tag /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static void Deserialize(XmlNode node, ConfigurationScope configScope) { NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); string id = NodeUtils.GetStringAttribute(prop, "id"); if (configScope.UseStatementNamespaces) { id = configScope.ApplyNamespace(id); } if (configScope.SqlIncludes.Contains(id)) { throw new ConfigurationException("Duplicate <sql>-include '" + id + "' found."); } else { configScope.SqlIncludes.Add(id, node); } }
/// <summary> /// Constructor /// </summary> /// <param name="configScope"></param> public DeSerializerFactory(ConfigurationScope configScope) { _serializerMap.Add("dynamic", new DynamicDeSerializer(configScope)); _serializerMap.Add("isEqual", new IsEqualDeSerializer(configScope)); _serializerMap.Add("isNotEqual", new IsNotEqualDeSerializer(configScope)); _serializerMap.Add("isGreaterEqual", new IsGreaterEqualDeSerializer(configScope)); _serializerMap.Add("isGreaterThan", new IsGreaterThanDeSerializer(configScope)); _serializerMap.Add("isLessEqual", new IsLessEqualDeSerializer(configScope)); _serializerMap.Add("isLessThan", new IsLessThanDeSerializer(configScope)); _serializerMap.Add("isNotEmpty", new IsNotEmptyDeSerializer(configScope)); _serializerMap.Add("isEmpty", new IsEmptyDeSerializer(configScope)); _serializerMap.Add("isNotNull", new IsNotNullDeSerializer(configScope)); _serializerMap.Add("isNotParameterPresent", new IsNotParameterPresentDeSerializer(configScope)); _serializerMap.Add("isNotPropertyAvailable", new IsNotPropertyAvailableDeSerializer(configScope)); _serializerMap.Add("isNull", new IsNullDeSerializer(configScope)); _serializerMap.Add("isParameterPresent", new IsParameterPresentDeSerializer(configScope)); _serializerMap.Add("isPropertyAvailable", new IsPropertyAvailableDeSerializer(configScope)); _serializerMap.Add("iterate", new IterateSerializer(configScope)); }
/// <summary> /// Deserialize a ParameterMap object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static ParameterMap Deserialize(XmlNode node, ConfigurationScope configScope) { ParameterMap parameterMap = new ParameterMap(configScope.DataExchangeFactory); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); configScope.ErrorContext.MoreInfo = "ParameterMap DeSerializer"; parameterMap.ExtendMap = NodeUtils.GetStringAttribute(prop, "extends"); parameterMap.Id = NodeUtils.GetStringAttribute(prop, "id"); parameterMap.ClassName = NodeUtils.GetStringAttribute(prop, "class"); configScope.ErrorContext.MoreInfo = "Initialize ParameterMap"; configScope.NodeContext = node; parameterMap.Initialize( configScope.DataSource.DbProvider.UsePositionalParameters, configScope ); parameterMap.BuildProperties(configScope); configScope.ErrorContext.MoreInfo = string.Empty; return parameterMap; }
/// <summary> /// Deserialize a ResultMap object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static ParameterProperty Deserialize(XmlNode node, ConfigurationScope configScope) { ParameterProperty property = new ParameterProperty(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); configScope.ErrorContext.MoreInfo = "ParameterPropertyDeSerializer"; property.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler"); property.CLRType = NodeUtils.GetStringAttribute(prop, "type"); property.ColumnName = NodeUtils.GetStringAttribute(prop, "column"); property.DbType = NodeUtils.GetStringAttribute(prop, "dbType", null); property.DirectionAttribute = NodeUtils.GetStringAttribute(prop, "direction"); property.NullValue = prop["nullValue"]; property.PropertyName = NodeUtils.GetStringAttribute(prop, "property"); property.Precision = NodeUtils.GetByteAttribute(prop, "precision", 0); property.Scale = NodeUtils.GetByteAttribute(prop, "scale", 0); property.Size = NodeUtils.GetIntAttribute(prop, "size", -1); return property; }
/// <summary> /// Deserialize a TypeHandler object /// </summary> /// <param name="node"></param> /// <param name="configScope"></param> /// <returns></returns> public static void Deserialize(XmlNode node, ConfigurationScope configScope) { TypeHandler handler = new TypeHandler(); NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties); handler.CallBackName = NodeUtils.GetStringAttribute(prop, "callback"); handler.ClassName = NodeUtils.GetStringAttribute(prop, "type"); handler.DbType = NodeUtils.GetStringAttribute(prop, "dbType"); handler.Initialize(); configScope.ErrorContext.MoreInfo = "Check the callback attribute '" + handler.CallBackName + "' (must be a classname)."; ITypeHandler typeHandler = null; Type type = configScope.SqlMapper.TypeHandlerFactory.GetType(handler.CallBackName); object impl = Activator.CreateInstance( type ); if (impl is ITypeHandlerCallback) { typeHandler = new CustomTypeHandler((ITypeHandlerCallback) impl); } else if (impl is ITypeHandler) { typeHandler = (ITypeHandler) impl; } else { throw new ConfigurationException("The callBack type is not a valid implementation of ITypeHandler or ITypeHandlerCallback"); } // configScope.ErrorContext.MoreInfo = "Check the type attribute '" + handler.ClassName + "' (must be a class name) or the dbType '" + handler.DbType + "' (must be a DbType type name)."; if (handler.DbType!= null && handler.DbType.Length > 0) { configScope.DataExchangeFactory.TypeHandlerFactory.Register(TypeUtils.ResolveType(handler.ClassName), handler.DbType, typeHandler); } else { configScope.DataExchangeFactory.TypeHandlerFactory.Register(TypeUtils.ResolveType(handler.ClassName), typeHandler); } }
/// <summary> /// /// </summary> /// <param name="configurationScope">The scope of the configuration</param> internal override void Initialize(ConfigurationScope configurationScope) { base.Initialize( configurationScope ); if (this.ParameterMap == null) { //throw new ConfigurationException("The parameterMap attribute is required in the procedure tag named '"+ this.Id +"'."); this.ParameterMap = configurationScope.SqlMapper.GetParameterMap(ConfigurationScope.EMPTY_PARAMETER_MAP); } }
/// <summary> /// Get the result properties and the subMap properties. /// </summary> /// <param name="configScope"></param> private void GetChildNode(ConfigurationScope configScope) { ResultProperty mapping = null; SubMap subMap = null; #region Load the parameters constructor XmlNodeList nodeList = configScope.NodeContext.SelectNodes( DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_CONSTRUCTOR_ARGUMENT), configScope.XmlNamespaceManager); if (nodeList.Count>0) { Type[] parametersType= new Type[nodeList.Count]; string[] parametersName = new string[nodeList.Count]; for( int i =0; i<nodeList.Count; i++) { ArgumentProperty argumentMapping = ArgumentPropertyDeSerializer.Deserialize( nodeList[i], configScope ); _parameters.Add( argumentMapping ); parametersName[i] = argumentMapping.ArgumentName; } ConstructorInfo constructorInfo = this.GetConstructor( _class, parametersName ); for(int i=0;i<_parameters.Count;i++) { ArgumentProperty argumentMapping = (ArgumentProperty)_parameters[i]; configScope.ErrorContext.MoreInfo = "initialize argument property : " + argumentMapping.ArgumentName; argumentMapping.Initialize( configScope, constructorInfo); parametersType[i] = argumentMapping.MemberType; } // Init the object factory _objectFactory = configScope.SqlMapper.ObjectFactory.CreateFactory(_class, parametersType); } else { if (Type.GetTypeCode(_class) == TypeCode.Object) { _objectFactory = configScope.SqlMapper.ObjectFactory.CreateFactory(_class, Type.EmptyTypes); } } #endregion #region Load the Result Properties foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes( DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_RESULT), configScope.XmlNamespaceManager) ) { mapping = ResultPropertyDeSerializer.Deserialize( resultNode, configScope ); configScope.ErrorContext.MoreInfo = "initialize result property: "+mapping.PropertyName; mapping.Initialize( configScope, _class ); _properties.Add( mapping ); } #endregion #region Load the Discriminator Property XmlNode discriminatorNode = configScope.NodeContext.SelectSingleNode(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_DISCRIMNATOR), configScope.XmlNamespaceManager); if (discriminatorNode != null) { configScope.ErrorContext.MoreInfo = "initialize discriminator"; this.Discriminator = DiscriminatorDeSerializer.Deserialize(discriminatorNode, configScope); this.Discriminator.SetMapping( configScope, _class ); } #endregion #region Load the SubMap Properties if (configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_SUBMAP), configScope.XmlNamespaceManager).Count>0 && this.Discriminator==null) { throw new ConfigurationException("The discriminator is null, but somehow a subMap was reached. This is a bug."); } foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_SUBMAP), configScope.XmlNamespaceManager) ) { configScope.ErrorContext.MoreInfo = "initialize subMap"; subMap = SubMapDeSerializer.Deserialize(resultNode, configScope); this.Discriminator.Add( subMap ); } #endregion }
/// <summary> /// Sets the object factory. /// </summary> public void SetObjectFactory(ConfigurationScope configScope) { Type[] parametersType = new Type[_parameters.Count]; for (int i = 0; i < _parameters.Count; i++) { ArgumentProperty argumentMapping = (ArgumentProperty)_parameters[i]; parametersType[i] = argumentMapping.MemberType; } // Init the object factory _objectFactory = configScope.SqlMapper.ObjectFactory.CreateFactory(_class, parametersType); }
/// <summary> /// Initialize the resultMap from an xmlNode.. /// </summary> /// <param name="configScope"></param> public void Initialize( ConfigurationScope configScope ) { try { _class = configScope.SqlMapper.TypeHandlerFactory.GetType(_className); _dataExchange = _dataExchangeFactory.GetDataExchangeForClass(_class); // Load the child node GetChildNode(configScope); // Verify that that each groupBy element correspond to a class member // of one of result property for (int i = 0; i < _groupByProperties.Count; i++) { string memberName = GroupByPropertyNames[i]; if (!_properties.Contains(memberName)) { throw new ConfigurationException( string.Format( "Could not configure ResultMap named \"{0}\". Check the groupBy attribute. Cause: there's no result property named \"{1}\".", _id, memberName)); } } } catch(Exception e) { throw new ConfigurationException( string.Format("Could not configure ResultMap named \"{0}\", Cause: {1}", _id, e.Message) , e); } }
/// <summary> /// Initializes a new instance of the <see cref="ResultMap"/> class. /// </summary> /// <param name="configScope">The config scope.</param> /// <param name="className">The output class name of the resultMap.</param> /// <param name="extendMap">The extend result map bame.</param> /// <param name="id">Identifier used to identify the resultMap amongst the others.</param> /// <param name="groupBy">The groupBy properties</param> public ResultMap(ConfigurationScope configScope, string id, string className, string extendMap, string groupBy) { _nullResultMap = new NullResultMap(); _dataExchangeFactory = configScope.DataExchangeFactory; _sqlMapNameSpace = configScope.SqlMapNamespace; if ((id == null) || (id.Length < 1)) { throw new ArgumentNullException("The id attribute is mandatory in a ResultMap tag."); } _id = configScope.ApplyNamespace(id); if ((className == null) || (className.Length < 1)) { throw new ArgumentNullException("The class attribute is mandatory in the ResultMap tag id:"+_id); } _className = className; _extendMap = extendMap; if (groupBy != null && groupBy.Length>0) { string[] groupByProperties = groupBy.Split(','); for (int i = 0; i < groupByProperties.Length; i++) { string memberName = groupByProperties[i].Trim(); _groupByPropertyNames.Add(memberName); } } }
/// <summary> /// Get the parameter properties child for the xmlNode parameter. /// </summary> /// <param name="configScope"></param> public void BuildProperties(ConfigurationScope configScope) { ParameterProperty property = null; foreach (XmlNode parameterNode in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_PARAMATER), configScope.XmlNamespaceManager)) { property = ParameterPropertyDeSerializer.Deserialize(parameterNode, configScope); property.Initialize(configScope, _parameterClass); AddParameterProperty(property); } }
/// <summary> /// /// </summary> /// <param name="configScope"></param> /// <param name="argumenType">The argument type</param> /// <param name="clrType"></param> /// <param name="dbType"></param> /// <returns></returns> public ITypeHandler ResolveTypeHandler(ConfigurationScope configScope, Type argumenType, string clrType, string dbType) { ITypeHandler handler = null; if (argumenType==null) { handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else if (typeof(IDictionary).IsAssignableFrom(argumenType)) { // IDictionary if (clrType ==null ||clrType.Length == 0) { handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { try { Type type = TypeUtils.ResolveType(clrType); handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType); } catch (Exception e) { #if dotnet2 throw new ConfigurationErrorsException("Error. Could not set TypeHandler. Cause: " + e.Message, e); #else throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e); #endif } } } else if (configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(argumenType, dbType) != null) { // Primitive handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(argumenType, dbType); } else { // .NET object if (clrType ==null || clrType.Length == 0) { handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { try { Type type = TypeUtils.ResolveType(clrType); handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType); } catch (Exception e) { #if dotnet2 throw new ConfigurationErrorsException("Error. Could not set TypeHandler. Cause: " + e.Message, e); #else throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e); #endif } } } return handler; }
/// <summary> /// /// </summary> /// <param name="configScope"></param> public IsLessThanDeSerializer(ConfigurationScope configScope) { _configScope = configScope; }
/// <summary> /// /// </summary> /// <param name="configScope"></param> public IsNotEqualDeSerializer(ConfigurationScope configScope) { _configScope = configScope; }
/// <summary> /// /// </summary> /// <param name="configScope"></param> public IsParameterPresentDeSerializer(ConfigurationScope configScope) { _configScope = configScope; }
/// <summary> /// /// </summary> /// <param name="configScope"></param> public IsPropertyAvailableDeSerializer(ConfigurationScope configScope) { _configScope = configScope; }
/// <summary> /// /// </summary> /// <param name="configScope"></param> public IsGreaterEqualDeSerializer(ConfigurationScope configScope) { _configScope = configScope; }
/// <summary> /// Initialize the Discriminator /// </summary> /// <param name="configScope"></param> public void Initialize(ConfigurationScope configScope) { // Set the ResultMaps int count = _subMaps.Count; for(int index=0; index<count; index++) { SubMap subMap = _subMaps[index] as SubMap; _resultMaps.Add(subMap.DiscriminatorValue, configScope.SqlMapper.GetResultMap( subMap.ResultMapName ) ); } }
/// <summary> /// Initilaize the underlying mapping /// </summary> /// <param name="configScope"></param> /// <param name="resultClass"></param> public void SetMapping(ConfigurationScope configScope, Type resultClass) { configScope.ErrorContext.MoreInfo = "Initialize discriminator mapping"; _mapping = new ResultProperty(); _mapping.ColumnName = _columnName; _mapping.ColumnIndex = _columnIndex; _mapping.CLRType = _clrType; _mapping.CallBackName = _callBackName; _mapping.DbType = _dbType; _mapping.NullValue = _nullValue; _mapping.Initialize( configScope, resultClass ); }