Exemplo n.º 1
0
        /// <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);
                }
            }
        }
        public static SubMap Deserialize(XmlNode node, ConfigurationScope configScope)
        {
            NameValueCollection attributes = NodeUtils.ParseAttributes(node, configScope.Properties);
            string stringAttribute         = NodeUtils.GetStringAttribute(attributes, "value");

            return(new SubMap(stringAttribute, configScope.ApplyNamespace(NodeUtils.GetStringAttribute(attributes, "resultMapping"))));
        }
Exemplo n.º 3
0
 public ResultMap(ConfigurationScope configScope, string id, string className, string extendMap, string groupBy)
 {
     _nullResultMap            = new NullResultMap();
     this._dataExchangeFactory = configScope.DataExchangeFactory;
     this._sqlMapNameSpace     = configScope.SqlMapNamespace;
     if ((id == null) || (id.Length < 1))
     {
         throw new ArgumentNullException("The id attribute is mandatory in a ResultMap tag.");
     }
     this._id = configScope.ApplyNamespace(id);
     if ((className == null) || (className.Length < 1))
     {
         throw new ArgumentNullException("The class attribute is mandatory in the ResultMap tag id:" + this._id);
     }
     this._className = className;
     this._extendMap = extendMap;
     if ((groupBy != null) && (groupBy.Length > 0))
     {
         string[] strArray = groupBy.Split(new char[] { ',' });
         for (int i = 0; i < strArray.Length; i++)
         {
             string str = strArray[i].Trim();
             this._groupByPropertyNames.Add(str);
         }
     }
 }
Exemplo n.º 4
0
        /// <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));
        }
        public static void Deserialize(XmlNode node, ConfigurationScope configScope)
        {
            string stringAttribute = NodeUtils.GetStringAttribute(NodeUtils.ParseAttributes(node, configScope.Properties), "id");

            if (configScope.UseStatementNamespaces)
            {
                stringAttribute = configScope.ApplyNamespace(stringAttribute);
            }
            if (configScope.SqlIncludes.Contains(stringAttribute))
            {
                throw new ConfigurationException("Duplicate <sql>-include '" + stringAttribute + "' found.");
            }
            configScope.SqlIncludes.Add(stringAttribute, node);
        }
        /// <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);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initialize an statement for the sqlMap.
 /// </summary>
 /// <param name="configurationScope">The scope of the configuration</param>
 internal virtual void Initialize(ConfigurationScope configurationScope)
 {
     if (_resultMapName.Length > 0)
     {
         string[] names = _resultMapName.Split(',');
         for (int i = 0; i < names.Length; i++)
         {
             string name = configurationScope.ApplyNamespace(names[i].Trim());
             _resultsMap.Add(configurationScope.SqlMapper.GetResultMap(name));
         }
     }
     if (_parameterMapName.Length > 0)
     {
         _parameterMap = configurationScope.SqlMapper.GetParameterMap(_parameterMapName);
     }
     if (_resultClassName.Length > 0)
     {
         string[] classNames = _resultClassName.Split(',');
         for (int i = 0; i < classNames.Length; i++)
         {
             _resultClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(classNames[i].Trim());
             IFactory resultClassFactory = null;
             if (Type.GetTypeCode(_resultClass) == TypeCode.Object &&
                 (_resultClass.IsValueType == false))
             {
                 resultClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(_resultClass, Type.EmptyTypes);
             }
             IDataExchange dataExchange = configurationScope.DataExchangeFactory.GetDataExchangeForClass(_resultClass);
             IResultMap    autoMap      = new AutoResultMap(_resultClass, resultClassFactory, dataExchange);
             _resultsMap.Add(autoMap);
         }
     }
     if (_parameterClassName.Length > 0)
     {
         _parameterClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(_parameterClassName);
     }
     if (_listClassName.Length > 0)
     {
         _listClass        = configurationScope.SqlMapper.TypeHandlerFactory.GetType(_listClassName);
         _listClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(_listClass, Type.EmptyTypes);
     }
 }
Exemplo n.º 8
0
 internal virtual void Initialize(ConfigurationScope configurationScope)
 {
     if (this._resultMapName.Length > 0)
     {
         string[] strArray = this._resultMapName.Split(new char[] { ',' });
         for (int i = 0; i < strArray.Length; i++)
         {
             string name = configurationScope.ApplyNamespace(strArray[i].Trim());
             this._resultsMap.Add(configurationScope.SqlMapper.GetResultMap(name));
         }
     }
     if (this._parameterMapName.Length > 0)
     {
         this._parameterMap = configurationScope.SqlMapper.GetParameterMap(this._parameterMapName);
     }
     if (this._resultClassName.Length > 0)
     {
         string[] strArray2 = this._resultClassName.Split(new char[] { ',' });
         for (int j = 0; j < strArray2.Length; j++)
         {
             this._resultClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(strArray2[j].Trim());
             IFactory resultClassFactory = null;
             if ((Type.GetTypeCode(this._resultClass) == TypeCode.Object) && !this._resultClass.IsValueType)
             {
                 resultClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(this._resultClass, Type.EmptyTypes);
             }
             IDataExchange dataExchangeForClass = configurationScope.DataExchangeFactory.GetDataExchangeForClass(this._resultClass);
             IResultMap    map = new AutoResultMap(this._resultClass, resultClassFactory, dataExchangeForClass);
             this._resultsMap.Add(map);
         }
     }
     if (this._parameterClassName.Length > 0)
     {
         this._parameterClass = configurationScope.SqlMapper.TypeHandlerFactory.GetType(this._parameterClassName);
     }
     if (this._listClassName.Length > 0)
     {
         this._listClass        = configurationScope.SqlMapper.TypeHandlerFactory.GetType(this._listClassName);
         this._listClassFactory = configurationScope.SqlMapper.ObjectFactory.CreateFactory(this._listClass, Type.EmptyTypes);
     }
 }