Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultMap"/> class.
        /// </summary>
        /// <param name="id">Identifier used to identify the resultMap amongst the others.</param>
        /// <param name="className">The output class name of the resultMap.</param>
        /// <param name="extendMap">The extend result map bame.</param>
        /// <param name="groupBy">The groupBy properties</param>
        /// <param name="keyColumns">The key columns.</param>
        /// <param name="type">The result type.</param>
        /// <param name="dataExchange">The data exchange.</param>
        /// <param name="objectFactory">The object factory.</param>
        /// <param name="typeHandlerFactory">The type handler factory.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="discriminator">The discriminator.</param>
        public ResultMap(
            string id,
            string className,
            string extendMap,
            string groupBy,
            string keyColumns,
            Type type,
            IDataExchange dataExchange,
            IFactory objectFactory,
            TypeHandlerFactory typeHandlerFactory,
            ResultPropertyCollection properties,
            ArgumentPropertyCollection parameters,
            Discriminator discriminator)
        {
            Contract.Require.That(id, Is.Not.Null & Is.Not.Empty).When("retrieving argument id in ResultMap constructor");
            Contract.Require.That(className, Is.Not.Null & Is.Not.Empty).When("retrieving argument className in ResultMap constructor");
            Contract.Require.That(type, Is.Not.Null).When("retrieving argument type in ResultMap constructor");
            Contract.Require.That(typeHandlerFactory, Is.Not.Null).When("retrieving argument typeHandlerFactory in ResultMap constructor");

            nullResultMap = new NullResultMap();

            this.id            = id;
            this.className     = className;
            this.extendMap     = extendMap;
            this.type          = type;
            this.dataExchange  = dataExchange;
            this.properties    = properties;
            this.parameters    = parameters;
            this.discriminator = discriminator;
            this.objectFactory = objectFactory;
            isSimpleType       = typeHandlerFactory.IsSimpleType(type);

            if (!string.IsNullOrEmpty(groupBy))
            {
                string[] props = groupBy.Split(',');
                for (int i = 0; i < props.Length; i++)
                {
                    string memberName = props[i].Trim();
                    groupByPropertyNames.Add(memberName);
                }

                InitializeGroupByProperties();
                CheckGroupBy();
            }

            if (!string.IsNullOrEmpty(keyColumns))
            {
                string[] columns = keyColumns.Split(',');
                for (int i = 0; i < columns.Length; i++)
                {
                    string column = columns[i].Trim();
                    keyPropertyNames.Add(column);
                }

                InitializeKeysProperties();
                CheckKeysProperties();
            }
        }
Example #2
0
        /// <summary>
        /// Create an instance Of result.
        /// </summary>
        /// <param name="parameters">An array of values that matches the number, order and type
        /// of the parameters for this constructor.</param>
        /// <returns>An object.</returns>
        public object CreateInstanceOfResult(object[] parameters)
        {
            if (!isSimpleType)
            {
                parameters = RaisePreCreateEvent(parameters);

                object instance = objectFactory.CreateInstance(parameters);

                instance = RaisePostCreateEvent(instance);

                return(instance);
            }
            return(TypeUtils.InstantiatePrimitiveType(type));
        }