コード例 #1
0
ファイル: SelectStrategy.cs プロジェクト: rasitha1/SqlBatis
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectStrategy"/> class.
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <param name="selectArrayStrategy">The select array strategy.</param>
        /// <param name="selectGenericListStrategy">The select generic list strategy.</param>
        /// <param name="selectListStrategy">The select list strategy.</param>
        /// <param name="selectObjectStrategy">The select object strategy.</param>
        public SelectStrategy(ResultProperty mapping,
                              IPropertyStrategy selectArrayStrategy,
                              IPropertyStrategy selectGenericListStrategy,
                              IPropertyStrategy selectListStrategy,
                              IPropertyStrategy selectObjectStrategy)
        {
            // Collection object or .NET object
            if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
            {
                _selectStrategy = selectArrayStrategy;
            }
            else if (mapping.SetAccessor.MemberType.IsGenericType &&
                     typeof(IList <>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()))
            {
                _selectStrategy = selectGenericListStrategy;
            }
            // Check if the object to Map implement 'IList' or is IList type
            // If yes the ResultProperty is map to a IList object
            else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
            {
                _selectStrategy = selectListStrategy;
            }

            else             // The ResultProperty is map to a .Net object
            {
                _selectStrategy = selectObjectStrategy;
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectStrategy"/> class.
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <param name="selectArrayStrategy">The select array strategy.</param>
        /// <param name="selectGenericListStrategy">The select generic list strategy.</param>
        /// <param name="selectListStrategy">The select list strategy.</param>
        /// <param name="selectObjectStrategy">The select object strategy.</param>
        public SelectStrategy(ResultProperty mapping,
            IPropertyStrategy selectArrayStrategy,
            IPropertyStrategy selectGenericListStrategy,
            IPropertyStrategy selectListStrategy,
            IPropertyStrategy selectObjectStrategy)
        {
            // Collection object or .NET object
            if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
            {
                _selectStrategy = selectArrayStrategy;
            }
            #if dotnet2
            else if (mapping.SetAccessor.MemberType.IsGenericType &&
                 typeof(IList<>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()) )
            {
                _selectStrategy = selectGenericListStrategy;
            }
            #endif
            // Check if the object to Map implement 'IList' or is IList type
            // If yes the ResultProperty is map to a IList object
            else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
            {
                _selectStrategy = selectListStrategy;
            }

            else // The ResultProperty is map to a .Net object
            {
                _selectStrategy = selectObjectStrategy;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectStrategy"/> class.
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <param name="selectArrayStrategy">The select array strategy.</param>
        /// <param name="selectGenericListStrategy">The select generic list strategy.</param>
        /// <param name="selectListStrategy">The select list strategy.</param>
        /// <param name="selectObjectStrategy">The select object strategy.</param>
		public SelectStrategy(ResultProperty mapping,
            IPropertyStrategy selectArrayStrategy,
            IPropertyStrategy selectGenericListStrategy,
            IPropertyStrategy selectListStrategy,
            IPropertyStrategy selectObjectStrategy)
		{
            Contract.Require.That(selectArrayStrategy, Is.Not.Null).When("retrieving argument selectArrayStrategy in SelectStrategy constructor");
            Contract.Require.That(selectGenericListStrategy, Is.Not.Null).When("retrieving argument selectGenericListStrategy in SelectStrategy constructor");
            Contract.Require.That(selectListStrategy, Is.Not.Null).When("retrieving argument selectListStrategy in SelectStrategy constructor");
            Contract.Require.That(selectObjectStrategy, Is.Not.Null).When("retrieving argument selectObjectStrategy in SelectStrategy constructor");

			// Collection object or .NET object		
			if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
			{
                selectStrategy = selectArrayStrategy;
			}
            else if (mapping.SetAccessor.MemberType.IsGenericType &&
                 typeof(IList<>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()) )
            {
                selectStrategy = selectGenericListStrategy;
            }
            // Check if the object to Map implement 'IList' or is IList type
			// If yes the ResultProperty is map to a IList object
            else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
			{
                selectStrategy = selectListStrategy;
			}

			else // The ResultProperty is map to a .Net object
			{
                selectStrategy = selectObjectStrategy;
			}
		}
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectStrategy"/> class.
        /// </summary>
        /// <param name="mapping">The mapping.</param>
        /// <param name="selectArrayStrategy">The select array strategy.</param>
        /// <param name="selectGenericListStrategy">The select generic list strategy.</param>
        /// <param name="selectListStrategy">The select list strategy.</param>
        /// <param name="selectObjectStrategy">The select object strategy.</param>
        public SelectStrategy(ResultProperty mapping,
                              IPropertyStrategy selectArrayStrategy,
                              IPropertyStrategy selectGenericListStrategy,
                              IPropertyStrategy selectListStrategy,
                              IPropertyStrategy selectObjectStrategy)
        {
            Contract.Require.That(selectArrayStrategy, Is.Not.Null).When("retrieving argument selectArrayStrategy in SelectStrategy constructor");
            Contract.Require.That(selectGenericListStrategy, Is.Not.Null).When("retrieving argument selectGenericListStrategy in SelectStrategy constructor");
            Contract.Require.That(selectListStrategy, Is.Not.Null).When("retrieving argument selectListStrategy in SelectStrategy constructor");
            Contract.Require.That(selectObjectStrategy, Is.Not.Null).When("retrieving argument selectObjectStrategy in SelectStrategy constructor");

            // Collection object or .NET object
            if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
            {
                selectStrategy = selectArrayStrategy;
            }
            else if (mapping.SetAccessor.MemberType.IsGenericType &&
                     typeof(IList <>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()))
            {
                selectStrategy = selectGenericListStrategy;
            }
            // Check if the object to Map implement 'IList' or is IList type
            // If yes the ResultProperty is map to a IList object
            else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
            {
                selectStrategy = selectListStrategy;
            }

            else             // The ResultProperty is map to a .Net object
            {
                selectStrategy = selectObjectStrategy;
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes the <see cref="PropertyStrategyFactory"/> class.
        /// </summary>
        static PropertyStrategyFactory()
        {
            _defaultStrategy   = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();
            _groupByStrategy   = new GroupByStrategy();

            _selectArrayStrategy       = new SelectArrayStrategy();
            _selectListStrategy        = new SelectListStrategy();
            _selectObjectStrategy      = new SelectObjectStrategy();
            _selectGenericListStrategy = new SelectGenericListStrategy();
        }
コード例 #6
0
        /// <summary>
        /// Initializes the <see cref="PropertyStrategyFactory"/> class.
        /// </summary>
        static PropertyStrategyFactory()
        {
            _defaultStrategy = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();
            _groupByStrategy = new GroupByStrategy();

            _selectArrayStrategy = new SelectArrayStrategy();
            _selectListStrategy = new SelectListStrategy();
            _selectObjectStrategy = new SelectObjectStrategy();
            _selectGenericListStrategy = new SelectGenericListStrategy();
        }
コード例 #7
0
        /// <summary>
        /// Initializes the <see cref="PropertyStrategyFactory"/> class.
        /// </summary>
        static PropertyStrategyFactory()
        {
            defaultStrategy   = new DefaultStrategy();
            resultMapStrategy = new ResultMapStrategy();

            selectArrayStrategy       = new SelectArrayStrategy();
            selectListStrategy        = new SelectListStrategy();
            selectObjectStrategy      = new SelectObjectStrategy();
            selectGenericListStrategy = new SelectGenericListStrategy();
            circularStrategy          = new CircularStrategy(resultMapStrategy);
            groupByStrategy           = new GroupByStrategy(resultMapStrategy, circularStrategy);
        }
コード例 #8
0
		/// <summary>
		/// Initializes the <see cref="PropertyStrategyFactory"/> class.
		/// </summary>
		static PropertyStrategyFactory()
		{
			defaultStrategy = new DefaultStrategy();
            resultMapStrategy = new ResultMapStrategy();

            selectArrayStrategy = new SelectArrayStrategy();
            selectListStrategy = new SelectListStrategy();
            selectObjectStrategy = new SelectObjectStrategy();
            selectGenericListStrategy = new SelectGenericListStrategy();
            circularStrategy = new CircularStrategy(resultMapStrategy);
            groupByStrategy = new GroupByStrategy(resultMapStrategy, circularStrategy);
		}
コード例 #9
0
        /// <summary>
        /// Initializes the <see cref="PropertyStrategyFactory"/> class.
        /// </summary>
        static PropertyStrategyFactory()
        {
            _defaultStrategy   = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();
            _groupByStrategy   = new GroupByStrategy();

            _selectArrayStrategy  = new SelectArrayStrategy();
            _selectListStrategy   = new SelectListStrategy();
            _selectObjectStrategy = new SelectObjectStrategy();

            //*********************** Added ***********************
            _selectDataTableStrategy = new SelectDataTableStrategy();
#if dotnet2
            _selectGenericListStrategy = new SelectGenericListStrategy();
#endif
        }
コード例 #10
0
 public SelectStrategy(ResultProperty mapping, IPropertyStrategy selectArrayStrategy, IPropertyStrategy selectGenericListStrategy, IPropertyStrategy selectListStrategy, IPropertyStrategy selectObjectStrategy)
 {
     if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
     {
         this._selectStrategy = selectArrayStrategy;
     }
     else if (mapping.SetAccessor.MemberType.IsGenericType && typeof(IList <>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()))
     {
         this._selectStrategy = selectGenericListStrategy;
     }
     else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
     {
         this._selectStrategy = selectListStrategy;
     }
     else
     {
         this._selectStrategy = selectObjectStrategy;
     }
 }
コード例 #11
0
 /// <summary>
 /// Initializes the <see cref="PropertyStrategyFactory"/> class.
 /// </summary>
 static GroupByStrategy()
 {
     _resultMapStrategy = new ResultMapStrategy();
 }
コード例 #12
0
ファイル: GroupByStrategy.cs プロジェクト: yhh1234/web_test
 /// <summary>
 /// Initializes the <see cref="GroupByStrategy"/> class.
 /// </summary>
 /// <param name="resultMapStrategy">The result map strategy.</param>
 /// <param name="circularResultMapStrategy">The circular result map strategy.</param>
 public GroupByStrategy(IPropertyStrategy resultMapStrategy, IPropertyStrategy circularResultMapStrategy)
 {
     this.resultMapStrategy         = resultMapStrategy;
     this.circularResultMapStrategy = circularResultMapStrategy;
 }
コード例 #13
0
 /// <summary>
 /// Initializes the <see cref="CircularStrategy"/> class.
 /// </summary>
 /// <param name="resultMapStrategy">The result map strategy.</param>
 public CircularStrategy(IPropertyStrategy resultMapStrategy)
 {
     this.resultMapStrategy = resultMapStrategy;
 }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultProperty"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="clrType">Type of the CLR.</param>
        /// <param name="callBackName">Name of the call back.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="isLazyLoad">if set to <c>true</c> [is lazy load].</param>
        /// <param name="nestedResultMapName">Name of the nested result map.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="select">The select.</param>
        /// <param name="resultClass">The result class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="typeHandler">The type handler.</param>
        public ResultProperty(
            string propertyName,
            string columnName,
            int columnIndex,
            string clrType,
            string callBackName,
            string dbType,
            bool isLazyLoad,
            string nestedResultMapName,
            string nullValue,
            string select,
            Type resultClass,
            DataExchangeFactory dataExchangeFactory,
            ITypeHandler typeHandler
            )
        {
            Contract.Require.That(propertyName, Is.Not.Null & Is.Not.Empty).When("retrieving argument propertyName in ResultProperty constructor");

            this.propertyName = propertyName;

            this.columnName          = columnName;
            this.callBackName        = callBackName;
            this.dbType              = dbType;
            this.clrType             = clrType;
            this.select              = select;
            this.nestedResultMapName = nestedResultMapName;
            this.isLazyLoad          = isLazyLoad;
            this.nullValue           = nullValue;
            this.columnIndex         = columnIndex;
            this.typeHandler         = typeHandler;

            #region isComplexMemberName
            if (propertyName.IndexOf('.') < 0)
            {
                isComplexMemberName = false;
            }
            else // complex member name FavouriteLineItem.Id
            {
                isComplexMemberName = true;
            }
            #endregion

            if (propertyName.Length > 0 &&
                propertyName != "value" &&
                !typeof(IDictionary).IsAssignableFrom(resultClass) &&
                !typeof(DataRow).IsAssignableFrom(resultClass))
            {
                #region SetAccessor
                if (!isComplexMemberName)
                {
                    setAccessor = dataExchangeFactory.AccessorFactory.SetAccessorFactory.CreateSetAccessor(resultClass, propertyName);
                }
                else // complex member name FavouriteLineItem.Id
                {
                    MemberInfo propertyInfo = ObjectProbe.GetMemberInfoForSetter(resultClass, propertyName);
                    string     memberName   = propertyName.Substring(propertyName.LastIndexOf('.') + 1);
                    setAccessor = dataExchangeFactory.AccessorFactory.SetAccessorFactory.CreateSetAccessor(propertyInfo.ReflectedType, memberName);
                }
                #endregion

                isGenericIList = TypeUtils.IsImplementGenericIListInterface(MemberType);
                isIList        = typeof(IList).IsAssignableFrom(MemberType);

                #region Set the list factory
                if (isGenericIList)
                {
                    if (MemberType.IsArray)
                    {
                        listFactory = arrayListFactory;
                    }
                    else
                    {
                        Type[] typeArgs = MemberType.GetGenericArguments();

                        if (typeArgs.Length == 0)// Custom collection which derive from List<T>
                        {
                            listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                        }
                        else
                        {
                            Type genericIList      = typeof(IList <>);
                            Type interfaceListType = genericIList.MakeGenericType(typeArgs);

                            Type genericList = typeof(List <>);
                            Type listType    = genericList.MakeGenericType(typeArgs);

                            if ((interfaceListType == MemberType) || (listType == MemberType))
                            {
                                Type constructedType = genericList.MakeGenericType(typeArgs);
                                listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(
                                    constructedType,
                                    Type.EmptyTypes);
                            }
                            else // Custom collection which derive from List<T>
                            {
                                listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                            }
                        }
                    }
                }
                else if (isIList)
                {
                    if (MemberType.IsArray)
                    {
                        listFactory = arrayListFactory;
                    }
                    else
                    {
                        if (MemberType == typeof(IList))
                        {
                            listFactory = arrayListFactory;
                        }
                        else // custom collection
                        {
                            listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                        }
                    }
                }
                #endregion
            }

            #region TypeHandler
            if (!string.IsNullOrEmpty(CallBackName))
            {
                try
                {
                    Type type = dataExchangeFactory.TypeHandlerFactory.GetType(CallBackName);
                    ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback)Activator.CreateInstance(type);
                    this.typeHandler = new CustomTypeHandler(typeHandlerCallback);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Error occurred during custom type handler configuration.  Cause: " + e.Message, e);
                }
            }
            else
            {
                if (typeHandler == null)
                {
                    //configScope.ErrorContext.MoreInfo = "Result property '" + propertyName + "' set the typeHandler attribute.";
                    this.typeHandler = dataExchangeFactory.TypeHandlerFactory.ResolveTypeHandler(resultClass, propertyName, clrType, dbType, true);
                }
            }
            #endregion

            #region LazyLoad
            if (IsLazyLoad)
            {
                lazyFactory = new LazyFactoryBuilder().GetLazyFactory(setAccessor.MemberType);
            }
            #endregion

            if (!GetType().IsSubclassOf(typeof(ResultProperty)))
            {
                propertyStrategy = PropertyStrategyFactory.Get(this);
            }
        }
コード例 #15
0
 /// <summary>
 /// Initializes the <see cref="PropertyStrategyFactory"/> class.
 /// </summary>
 static GroupByStrategy()
 {
     _resultMapStrategy = new ResultMapStrategy();
 }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultProperty"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="clrType">Type of the CLR.</param>
        /// <param name="callBackName">Name of the call back.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="isLazyLoad">if set to <c>true</c> [is lazy load].</param>
        /// <param name="nestedResultMapName">Name of the nested result map.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="select">The select.</param>
        /// <param name="resultClass">The result class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="typeHandler">The type handler.</param>
		public ResultProperty(
            string propertyName,
            string columnName,
            int columnIndex,
            string clrType,
            string callBackName,
            string dbType,
            bool isLazyLoad,
            string nestedResultMapName,
            string nullValue,
            string select,
            Type resultClass,
            DataExchangeFactory dataExchangeFactory,
            ITypeHandler typeHandler
            )
		{
            Contract.Require.That(propertyName, Is.Not.Null & Is.Not.Empty).When("retrieving argument propertyName in ResultProperty constructor");

            this.propertyName = propertyName;

            this.columnName = columnName;
            this.callBackName = callBackName;
            this.dbType = dbType;
            this.clrType = clrType;
            this.select = select;
            this.nestedResultMapName = nestedResultMapName;
            this.isLazyLoad = isLazyLoad;
            this.nullValue = nullValue;
            this.columnIndex = columnIndex;
            this.typeHandler = typeHandler;

            #region isComplexMemberName
            if (propertyName.IndexOf('.') < 0)
            {
                isComplexMemberName = false;
            }
            else // complex member name FavouriteLineItem.Id
            {
                isComplexMemberName = true;
            } 
            #endregion			
            
            if ( propertyName.Length>0 && 
				 propertyName != "value" && 
				!typeof(IDictionary).IsAssignableFrom(resultClass)&&
                !typeof(DataRow).IsAssignableFrom(resultClass)) 
			{   
                #region SetAccessor
                if (!isComplexMemberName)
                {
                    setAccessor = dataExchangeFactory.AccessorFactory.SetAccessorFactory.CreateSetAccessor(resultClass, propertyName);
                }
                else // complex member name FavouriteLineItem.Id
                {
                    MemberInfo propertyInfo = ObjectProbe.GetMemberInfoForSetter(resultClass, propertyName);
                    string memberName = propertyName.Substring(propertyName.LastIndexOf('.') + 1);
                    setAccessor = dataExchangeFactory.AccessorFactory.SetAccessorFactory.CreateSetAccessor(propertyInfo.ReflectedType, memberName);
                }
                #endregion

                isGenericIList = TypeUtils.IsImplementGenericIListInterface(MemberType);
                isIList = typeof(IList).IsAssignableFrom(MemberType);
                    
                #region Set the list factory
                if (isGenericIList)
                {
                    if (MemberType.IsArray)
                    {
                        listFactory = arrayListFactory;
                    }
                    else
                    {
                        Type[] typeArgs = MemberType.GetGenericArguments();

                        if (typeArgs.Length == 0)// Custom collection which derive from List<T>
                        {
                            listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                        }
                        else
                        {
                            Type genericIList = typeof(IList<>);
                            Type interfaceListType = genericIList.MakeGenericType(typeArgs);

                            Type genericList = typeof(List<>);
                            Type listType = genericList.MakeGenericType(typeArgs);

                            if ((interfaceListType == MemberType) || (listType == MemberType))
                            {
                                Type constructedType = genericList.MakeGenericType(typeArgs);
                                listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(
                                    constructedType,
                                    Type.EmptyTypes);
                            }
                            else // Custom collection which derive from List<T>
                            {
                                listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                            }
                        }
                    }
                }
                else if (isIList)
                {
                    if (MemberType.IsArray)
                    {
                        listFactory = arrayListFactory;
                    }
                    else
                    {
                        if (MemberType == typeof(IList))
                        {
                            listFactory = arrayListFactory;
                        }
                        else // custom collection
                        {
                            listFactory = dataExchangeFactory.ObjectFactory.CreateFactory(MemberType, Type.EmptyTypes);
                        }
                    }
                } 
                #endregion
			}

            #region TypeHandler
            if (!string.IsNullOrEmpty(CallBackName))
            {
                try
                {
                    Type type = dataExchangeFactory.TypeHandlerFactory.GetType(CallBackName);
                    ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback)Activator.CreateInstance(type);
                    this.typeHandler = new CustomTypeHandler(typeHandlerCallback);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Error occurred during custom type handler configuration.  Cause: " + e.Message, e);
                }
            }
            else
            {
                if (typeHandler == null)
                {
                    //configScope.ErrorContext.MoreInfo = "Result property '" + propertyName + "' set the typeHandler attribute.";
                    this.typeHandler = dataExchangeFactory.TypeHandlerFactory.ResolveTypeHandler(resultClass, propertyName, clrType, dbType, true);
                }
            } 
            #endregion
                
            #region LazyLoad
            if (IsLazyLoad)
            {
                lazyFactory = new LazyFactoryBuilder().GetLazyFactory(setAccessor.MemberType);
            } 
            #endregion

            if (!GetType().IsSubclassOf(typeof(ResultProperty)))
            {
                propertyStrategy = PropertyStrategyFactory.Get(this);
            }
        }
コード例 #17
0
ファイル: GroupByStrategy.cs プロジェクト: reckcn/CSharp
        /// <summary>
        /// Initializes the <see cref="GroupByStrategy"/> class.
        /// </summary>
        /// <param name="resultMapStrategy">The result map strategy.</param>
        /// <param name="circularResultMapStrategy">The circular result map strategy.</param>
        public GroupByStrategy(IPropertyStrategy resultMapStrategy, IPropertyStrategy circularResultMapStrategy)
		{
            this.resultMapStrategy = resultMapStrategy;
            this.circularResultMapStrategy = circularResultMapStrategy;
		}
コード例 #18
0
        static bool TryAddPropertyFromElement(ITypeMapping typeMapping, ICollection <XElement> elementList, PropertyInfo property, IPropertyStrategy propertyStrategy, string name)
        {
            var element = TakeElement(elementList, name);

            if (element == null)
            {
                return(false);
            }

            var mapper          = propertyStrategy.Mapper ?? MapperSelector.GetFor(property.PropertyType);
            var propertyMapping = new MappingFromElement(element, property, mapper);

            typeMapping.Include(propertyMapping);
            return(true);
        }
コード例 #19
0
        static bool TryAddPropertyFromAttribute(Type type, ITypeMapping typeMapping, ICollection <XAttribute> attributeList, PropertyInfo property, IPropertyStrategy propertyStrategy, string name)
        {
            var attribute = TakeAttribute(attributeList, name);

            if (attribute == null)
            {
                return(false);
            }

            if (propertyStrategy.Mapper != null)
            {
                throw new AutoConfigMappingException(
                          string.Format(
                              "Custom IMapper '{0}' was configured for mapping property '{1}' of '{2}'. A custom IMapper cannot be specified when mapping from an attribute.",
                              propertyStrategy.Mapper, property.Name, type));
            }

            var propertyMapping = new MappingFromAttribute(attribute, property);

            typeMapping.Include(propertyMapping);

            return(true);
        }
コード例 #20
0
        /// <summary>
        /// Initializes the <see cref="CircularStrategy"/> class.
        /// </summary>
        /// <param name="resultMapStrategy">The result map strategy.</param>
        public CircularStrategy(IPropertyStrategy resultMapStrategy)
		{
            this.resultMapStrategy = resultMapStrategy;
		}