Пример #1
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,
            IArgumentStrategy selectArrayStrategy,
            IArgumentStrategy selectGenericListStrategy,
            IArgumentStrategy selectListStrategy,
            IArgumentStrategy selectObjectStrategy)
        {
            // Collection object or .NET object
            if (mapping.MemberType.BaseType == typeof(Array))
            {
                _selectStrategy = selectArrayStrategy;
            }
            else if (mapping.MemberType.IsGenericType &&
                 typeof(IList<>).IsAssignableFrom(mapping.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.MemberType))
            {
                _selectStrategy = selectListStrategy;
            }

            else // The ResultProperty is map to a .Net object
            {
                _selectStrategy = selectObjectStrategy;
            }
        }
        /// <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,
                              IArgumentStrategy selectArrayStrategy,
                              IArgumentStrategy selectGenericListStrategy,
                              IArgumentStrategy selectListStrategy,
                              IArgumentStrategy selectObjectStrategy)
        {
            // Collection object or .NET object
            if (mapping.MemberType.BaseType == typeof(Array))
            {
                _selectStrategy = selectArrayStrategy;
            }

            else if (mapping.MemberType.IsGenericType &&
                     typeof(IList <>).IsAssignableFrom(mapping.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.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="ArgumentProperty"/> class.
        /// </summary>
        /// <param name="argumentName">Name of the argument.</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="nestedResultMapName">Name of the nested result map.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="select">The select.</param>
        /// <param name="type">The argument type.</param>
        /// <param name="resultClass">The result class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="typeHandler">The type handler.</param>
        public ArgumentProperty(
            string argumentName,
            string columnName,
            int columnIndex,
            string clrType,
            string callBackName,
            string dbType,
            string nestedResultMapName,
            string nullValue,
            string select,
            Type type,
            Type resultClass,
            DataExchangeFactory dataExchangeFactory,
            ITypeHandler typeHandler
            )
            : base("value", columnName, columnIndex, clrType, callBackName, dbType, false, nestedResultMapName, nullValue, select, resultClass,
                   dataExchangeFactory, typeHandler)
        {
            Contract.Require.That(argumentName, Is.Not.Null & Is.Not.Empty).When("retrieving argument argumentName in ArgumentProperty constructor");
            Contract.Require.That(type, Is.Not.Null & Is.Not.Empty).When("retrieving argument type in ArgumentProperty constructor");
            Contract.Require.That(resultClass, Is.Not.Null & Is.Not.Empty).When("retrieving argument resultClass in ArgumentProperty constructor");

            this.argumentName = argumentName;
            this.type         = type;

            argumentStrategy = ArgumentStrategyFactory.Get(this);
        }
Пример #4
0
 public InstructionArgument(string name, ushort size, ushort offset, IArgumentStrategy strategy = null)
 {
     Name     = name;
     Size     = size;
     Offset   = offset;
     Strategy = strategy ?? new DefaultStrategy();
 }
Пример #5
0
        /// <summary>
        /// Initializes the <see cref="ArgumentStrategyFactory"/> class.
        /// </summary>
        static ArgumentStrategyFactory()
        {
            _defaultStrategy   = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();

            _selectArrayStrategy       = new SelectArrayStrategy();
            _selectListStrategy        = new SelectListStrategy();
            _selectObjectStrategy      = new SelectObjectStrategy();
            _selectGenericListStrategy = new SelectGenericListStrategy();
        }
        /// <summary>
        /// Initializes the <see cref="ArgumentStrategyFactory"/> class.
        /// </summary>
        static ArgumentStrategyFactory()
        {
            _defaultStrategy = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();

            _selectArrayStrategy = new SelectArrayStrategy();
            _selectListStrategy = new SelectListStrategy();
            _selectObjectStrategy = new SelectObjectStrategy();
            _selectGenericListStrategy = new SelectGenericListStrategy();
        }
Пример #7
0
        /// <summary>
        /// Initializes the <see cref="ArgumentStrategyFactory"/> class.
        /// </summary>
        static ArgumentStrategyFactory()
        {
            _defaultStrategy   = new DefaultStrategy();
            _resultMapStrategy = new ResultMapStrategy();

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

            //*********************** Added ***********************
            _selectDataTableStrategy = new SelectDataTableStrategy();
#if dotnet2
            _selectGenericListStrategy = new SelectGenericListStrategy();
#endif
        }
Пример #8
0
 public SelectStrategy(ResultProperty mapping, IArgumentStrategy selectArrayStrategy, IArgumentStrategy selectGenericListStrategy, IArgumentStrategy selectListStrategy, IArgumentStrategy selectObjectStrategy)
 {
     if (mapping.MemberType.BaseType == typeof(Array))
     {
         this._selectStrategy = selectArrayStrategy;
     }
     else if (mapping.MemberType.IsGenericType && typeof(IList <>).IsAssignableFrom(mapping.MemberType.GetGenericTypeDefinition()))
     {
         this._selectStrategy = selectGenericListStrategy;
     }
     else if (typeof(IList).IsAssignableFrom(mapping.MemberType))
     {
         this._selectStrategy = selectListStrategy;
     }
     else
     {
         this._selectStrategy = selectObjectStrategy;
     }
 }
Пример #9
0
 public Instruction AddArgument(string name, ushort size, ushort offset = 0, IArgumentStrategy strategy = null)
 {
     _arguments[name] = new InstructionArgument(name, size, offset, strategy);
     return(this);
 }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArgumentProperty"/> class.
        /// </summary>
        /// <param name="argumentName">Name of the argument.</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="nestedResultMapName">Name of the nested result map.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="select">The select.</param>
        /// <param name="type">The argument type.</param>
        /// <param name="resultClass">The result class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="typeHandler">The type handler.</param>
		public ArgumentProperty(
            string    argumentName,
            string    columnName,
            int       columnIndex,
            string    clrType,
            string    callBackName,
            string    dbType,
            string    nestedResultMapName,
            string    nullValue,
            string    select,
            Type      type,
            Type      resultClass,
            DataExchangeFactory dataExchangeFactory,
            ITypeHandler typeHandler
            )
            : base("value", columnName, columnIndex, clrType, callBackName, dbType, false, nestedResultMapName, nullValue, select, resultClass,
            dataExchangeFactory, typeHandler)
		{
            Contract.Require.That(argumentName, Is.Not.Null & Is.Not.Empty).When("retrieving argument argumentName in ArgumentProperty constructor");
            Contract.Require.That(type, Is.Not.Null & Is.Not.Empty).When("retrieving argument type in ArgumentProperty constructor");
            Contract.Require.That(resultClass, Is.Not.Null & Is.Not.Empty).When("retrieving argument resultClass in ArgumentProperty constructor");

            this.argumentName = argumentName;
            this.type = type;

            argumentStrategy = ArgumentStrategyFactory.Get(this);
		}