public void BuildProperties(ConfigurationScope configScope) { ParameterProperty property = null; foreach (XmlNode node in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix("parameter"), configScope.XmlNamespaceManager)) { property = ParameterPropertyDeSerializer.Deserialize(node, configScope); property.Initialize(configScope, this._parameterClass); this.AddParameterProperty(property); } }
/// <summary> /// Parse inline parameter with syntax as /// #propertyName:dbType:nullValue# /// </summary> /// <param name="token"></param> /// <param name="parameterClassType"></param> /// <param name="scope"></param> /// <returns></returns> private ParameterProperty OldParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty mapping = new ParameterProperty(); if (token.IndexOf(PARAM_DELIM) > -1) { StringTokenizer paramParser = new StringTokenizer(token, PARAM_DELIM, true); IEnumerator enumeratorParam = paramParser.GetEnumerator(); int n1 = paramParser.TokenNumber; if (n1 == 3) { enumeratorParam.MoveNext(); string propertyName = ((string)enumeratorParam.Current).Trim(); mapping.PropertyName = propertyName; enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string dBType = ((string)enumeratorParam.Current).Trim(); mapping.DbType = dBType; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, propertyName, null, dBType); } mapping.TypeHandler = handler; mapping.Initialize( scope, parameterClassType ); } else if (n1 >= 5) { enumeratorParam.MoveNext(); string propertyName = ((string)enumeratorParam.Current).Trim(); enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string dBType = ((string)enumeratorParam.Current).Trim(); enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string nullValue = ((string)enumeratorParam.Current).Trim(); while (enumeratorParam.MoveNext()) { nullValue = nullValue + ((string)enumeratorParam.Current).Trim(); } mapping.PropertyName = propertyName; mapping.DbType = dBType; mapping.NullValue = nullValue; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, propertyName, null, dBType); } mapping.TypeHandler = handler; mapping.Initialize( scope, parameterClassType ); } else { throw new ConfigurationException("Incorrect inline parameter map format: " + token); } } else { mapping.PropertyName = token; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, token, null, null); } mapping.TypeHandler = handler; mapping.Initialize( scope, parameterClassType ); } return mapping; }
/// <summary> /// Parse inline parameter with syntax as /// #propertyName,type=string,dbype=Varchar,direction=Input,nullValue=N/A,handler=string# /// </summary> /// <param name="token"></param> /// <param name="parameterClassType"></param> /// <param name="scope"></param> /// <returns></returns> private ParameterProperty NewParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty mapping = new ParameterProperty(); StringTokenizer paramParser = new StringTokenizer(token, "=,", false); IEnumerator enumeratorParam = paramParser.GetEnumerator(); enumeratorParam.MoveNext(); mapping.PropertyName = ((string)enumeratorParam.Current).Trim(); while (enumeratorParam.MoveNext()) { string field = (string)enumeratorParam.Current; if (enumeratorParam.MoveNext()) { string value = (string)enumeratorParam.Current; if ("type".Equals(field)) { mapping.CLRType = value; } else if ("dbType".Equals(field)) { mapping.DbType = value; } else if ("direction".Equals(field)) { mapping.DirectionAttribute = value; } else if ("nullValue".Equals(field)) { mapping.NullValue = value; } else if ("handler".Equals(field)) { mapping.CallBackName = value; } else { throw new DataMapperException("Unrecognized parameter mapping field: '" + field + "' in " + token); } } else { throw new DataMapperException("Incorrect inline parameter map format (missmatched name=value pairs): " + token); } } if (mapping.CallBackName.Length >0) { mapping.Initialize( scope, parameterClassType ); } else { ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler( scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, mapping.PropertyName, mapping.CLRType, mapping.DbType ); } mapping.TypeHandler = handler; mapping.Initialize( scope, parameterClassType ); } return mapping; }
/// <summary> /// Parse inline parameter with syntax as /// #propertyName:dbType:nullValue# /// </summary> /// <param name="token"></param> /// <param name="parameterClassType"></param> /// <param name="scope"></param> /// <returns></returns> private ParameterProperty OldParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty mapping = new ParameterProperty(); if (token.IndexOf(PARAM_DELIM) > -1) { StringTokenizer paramParser = new StringTokenizer(token, PARAM_DELIM, true); IEnumerator enumeratorParam = paramParser.GetEnumerator(); int n1 = paramParser.TokenNumber; if (n1 == 3) { enumeratorParam.MoveNext(); string propertyName = ((string)enumeratorParam.Current).Trim(); mapping.PropertyName = propertyName; enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string dBType = ((string)enumeratorParam.Current).Trim(); mapping.DbType = dBType; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, propertyName, null, dBType); } mapping.TypeHandler = handler; mapping.Initialize(scope, parameterClassType); } else if (n1 >= 5) { enumeratorParam.MoveNext(); string propertyName = ((string)enumeratorParam.Current).Trim(); enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string dBType = ((string)enumeratorParam.Current).Trim(); enumeratorParam.MoveNext(); enumeratorParam.MoveNext(); //ignore ":" string nullValue = ((string)enumeratorParam.Current).Trim(); while (enumeratorParam.MoveNext()) { nullValue = nullValue + ((string)enumeratorParam.Current).Trim(); } mapping.PropertyName = propertyName; mapping.DbType = dBType; mapping.NullValue = nullValue; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, propertyName, null, dBType); } mapping.TypeHandler = handler; mapping.Initialize(scope, parameterClassType); } else { throw new ConfigurationException("Incorrect inline parameter map format: " + token); } } else { mapping.PropertyName = token; ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, token, null, null); } mapping.TypeHandler = handler; mapping.Initialize(scope, parameterClassType); } return(mapping); }
/// <summary> /// Parse inline parameter with syntax as /// #propertyName,type=string,dbype=Varchar,direction=Input,nullValue=N/A,handler=string# /// </summary> /// <param name="token"></param> /// <param name="parameterClassType"></param> /// <param name="scope"></param> /// <returns></returns> private ParameterProperty NewParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty mapping = new ParameterProperty(); StringTokenizer paramParser = new StringTokenizer(token, "=,", false); IEnumerator enumeratorParam = paramParser.GetEnumerator(); enumeratorParam.MoveNext(); mapping.PropertyName = ((string)enumeratorParam.Current).Trim(); while (enumeratorParam.MoveNext()) { string field = (string)enumeratorParam.Current; if (enumeratorParam.MoveNext()) { string value = (string)enumeratorParam.Current; if ("type".Equals(field)) { mapping.CLRType = value; } else if ("dbType".Equals(field)) { mapping.DbType = value; } else if ("direction".Equals(field)) { mapping.DirectionAttribute = value; } else if ("nullValue".Equals(field)) { mapping.NullValue = value; } else if ("handler".Equals(field)) { mapping.CallBackName = value; } else { throw new DataMapperException("Unrecognized parameter mapping field: '" + field + "' in " + token); } } else { throw new DataMapperException("Incorrect inline parameter map format (missmatched name=value pairs): " + token); } } if (mapping.CallBackName.Length > 0) { mapping.Initialize(scope, parameterClassType); } else { ITypeHandler handler = null; if (parameterClassType == null) { handler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler = ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, mapping.PropertyName, mapping.CLRType, mapping.DbType); } mapping.TypeHandler = handler; mapping.Initialize(scope, parameterClassType); } return(mapping); }
private ParameterProperty OldParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty property = new ParameterProperty(); if (token.IndexOf(":") > -1) { StringTokenizer tokenizer = new StringTokenizer(token, ":", true); IEnumerator enumerator = tokenizer.GetEnumerator(); int tokenNumber = tokenizer.TokenNumber; if (tokenNumber == 3) { enumerator.MoveNext(); string str = ((string)enumerator.Current).Trim(); property.PropertyName = str; enumerator.MoveNext(); enumerator.MoveNext(); string str2 = ((string)enumerator.Current).Trim(); property.DbType = str2; ITypeHandler unkownTypeHandler = null; if (parameterClassType == null) { unkownTypeHandler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { unkownTypeHandler = this.ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, str, null, str2); } property.TypeHandler = unkownTypeHandler; property.Initialize(scope, parameterClassType); return(property); } if (tokenNumber < 5) { throw new ConfigurationException("Incorrect inline parameter map format: " + token); } enumerator.MoveNext(); string propertyName = ((string)enumerator.Current).Trim(); enumerator.MoveNext(); enumerator.MoveNext(); string dbType = ((string)enumerator.Current).Trim(); enumerator.MoveNext(); enumerator.MoveNext(); string str5 = ((string)enumerator.Current).Trim(); while (enumerator.MoveNext()) { str5 = str5 + ((string)enumerator.Current).Trim(); } property.PropertyName = propertyName; property.DbType = dbType; property.NullValue = str5; ITypeHandler handler2 = null; if (parameterClassType == null) { handler2 = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler2 = this.ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, propertyName, null, dbType); } property.TypeHandler = handler2; property.Initialize(scope, parameterClassType); return(property); } property.PropertyName = token; ITypeHandler handler3 = null; if (parameterClassType == null) { handler3 = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { handler3 = this.ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, token, null, null); } property.TypeHandler = handler3; property.Initialize(scope, parameterClassType); return(property); }
private ParameterProperty NewParseMapping(string token, Type parameterClassType, IScope scope) { ParameterProperty property = new ParameterProperty(); IEnumerator enumerator = new StringTokenizer(token, "=,", false).GetEnumerator(); enumerator.MoveNext(); property.PropertyName = ((string)enumerator.Current).Trim(); while (enumerator.MoveNext()) { string current = (string)enumerator.Current; if (!enumerator.MoveNext()) { throw new DataMapperException("Incorrect inline parameter map format (missmatched name=value pairs): " + token); } string str2 = (string)enumerator.Current; if (!"type".Equals(current)) { if (!"dbType".Equals(current)) { if (!"direction".Equals(current)) { if (!"nullValue".Equals(current)) { if (!"handler".Equals(current)) { throw new DataMapperException("Unrecognized parameter mapping field: '" + current + "' in " + token); } property.CallBackName = str2; } else { property.NullValue = str2; } } else { property.DirectionAttribute = str2; } continue; } property.DbType = str2; } else { property.CLRType = str2; continue; } } if (property.CallBackName.Length > 0) { property.Initialize(scope, parameterClassType); return(property); } ITypeHandler unkownTypeHandler = null; if (parameterClassType == null) { unkownTypeHandler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); } else { unkownTypeHandler = this.ResolveTypeHandler(scope.DataExchangeFactory.TypeHandlerFactory, parameterClassType, property.PropertyName, property.CLRType, property.DbType); } property.TypeHandler = unkownTypeHandler; property.Initialize(scope, parameterClassType); return(property); }