/// <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> /// 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 mismatched name=value pairs): " + token); } } if (!string.IsNullOrEmpty(mapping.CallBackName)) { 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); }