Example #1
0
 /// <summary>
 /// Set the value of an object property.
 /// </summary>
 /// <param name="target">The object to set the property.</param>
 /// <param name="property">The result property to use.</param>
 /// <param name="dataBaseValue">The database value to set.</param>
 public void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue)
 {
     _dataExchange.SetData(ref target, property, dataBaseValue);
 }
Example #2
0
 /// <summary>
 /// Set the value of an object property.
 /// </summary>
 /// <param name="target">The object to set the property.</param>
 /// <param name="property">The result property to use.</param>
 /// <param name="dataBaseValue">The database value to set.</param>
 public void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue)
 {
     throw new Exception("The method or operation is not implemented.");
 }
		/// <summary>
		/// Remove a ResultProperty of the collection.
		/// </summary>
		public void Remove(ResultProperty value) 
		{
			for(int i = 0; i < _count; i++) 
			{
				if(_innerList[i].PropertyName==value.PropertyName)
				{
					RemoveAt(i);
					return;
				}
			}

		}
Example #4
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>An <see cref="ResultProperty"/></returns>
        public ResultProperty Clone()
        {
            ResultProperty resultProperty = new ResultProperty();

            resultProperty.CLRType = this.CLRType;
            resultProperty.CallBackName = this.CallBackName;
            resultProperty.ColumnIndex = this.ColumnIndex;
            resultProperty.ColumnName = this.ColumnName;
            resultProperty.DbType = this.DbType;
            resultProperty.IsLazyLoad = this.IsLazyLoad;
            resultProperty.NestedResultMapName = this.NestedResultMapName;
            resultProperty.NullValue = this.NullValue;
            resultProperty.PropertyName = this.PropertyName;
            resultProperty.Select = this.Select;

            return resultProperty;
        }
		/// <summary>
		/// Indicate if a ResultProperty is in the collection
		/// </summary>
		/// <param name="value">A ResultProperty</param>
		/// <returns>True fi is in</returns>
		public bool Contains(ResultProperty value) 
		{
		    return Contains(value.PropertyName);
		}
		/// <summary>
		/// Insert a ResultProperty in the collection.
		/// </summary>
		/// <param name="index">Index where to insert.</param>
		/// <param name="value">A ResultProperty</param>
		public void Insert(int index, ResultProperty value) 
		{
			if (index < 0 || index > _count) 
			{
				throw new ArgumentOutOfRangeException("index");
			}
			
			Resize(_count + 1);
			Array.Copy(_innerList, index, _innerList, index + 1, _count - index);
			_innerList[index] = value;
			_count++;
		}
        /// <summary>
        /// Add an ResultProperty
        /// </summary>
        /// <param name="value"></param>
        /// <returns>Index</returns>
        public int Add(ResultProperty value) 
		{
			Resize(_count + 1);
			int index = _count++;
			_innerList[index] = value;

			return index;
		}
		/// <summary>
		/// Add a list of ResultProperty to the collection
		/// </summary>
		/// <param name="value"></param>
		public void AddRange(ResultProperty[] value) 
		{
			for (int i = 0;   i < value.Length; i++) 
			{
				Add(value[i]);
			}
		}
Example #9
0
 /// <summary>
 /// Set the value of an object property.
 /// </summary>
 /// <param name="target">The object to set the property.</param>
 /// <param name="property">The result property to use.</param>
 /// <param name="dataBaseValue">The database value to set.</param>
 public void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue)
 {
     _dataExchange.SetData(ref target, property, dataBaseValue);
 }
Example #10
0
 /// <summary>
 /// Set the value of an object property.
 /// </summary>
 /// <param name="target">The object to set the property.</param>
 /// <param name="property">The result property to use.</param>
 /// <param name="dataBaseValue">The database value to set.</param>
 public void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #11
0
        /// <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
        }
Example #12
0
 /// <summary>
 /// Indicate if a ResultProperty is in the collection
 /// </summary>
 /// <param name="value">A ResultProperty</param>
 /// <returns>True fi is in</returns>
 public bool Contains(ResultProperty value)
 {
     return(Contains(value.PropertyName));
 }
Example #13
0
		/// <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 );
		}