Exemplo n.º 1
0
        /// <summary>
        ///     Creates a new Instance based on possible Ctor's and the given
        ///     <paramref name="reader" />
        /// </summary>
        /// <returns></returns>
        public static object SetPropertysViaReflection(
            this DbClassInfoCache type,
            IDataRecord reader,
            DbAccessType?accessType = null,
            DbConfig config         = null)
        {
            if (reader == null)
            {
                return(null);
            }

            bool created;
            var  source = DbAccessLayer.CreateInstance(type, reader, out created);

            if (created)
            {
                return(source);
            }

            if (config == null)
            {
                config = new DbConfig(true);
            }

#pragma warning disable 618
            return(DbAccessLayer.ReflectionPropertySet(config, source, type, reader, null, accessType));

#pragma warning restore 618
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates a new Instance based on possible Ctor's and the given
        ///     <paramref name="reader" />
        /// </summary>
        /// <returns></returns>
        public static object SetPropertiesViaReflection(
            this DbClassInfoCache type,
            XmlDataRecord reader,
            DbAccessType?accessType = null,
            DbConfig config         = null)
        {
            if (reader == null)
            {
                return(null);
            }

            var eagerReader = new EagarDataRecord();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                eagerReader.Add(eagerReader.GetName(i), eagerReader[i]);
            }

            bool created;
            var  source = DbAccessLayer.CreateInstance(type, eagerReader, out created);

            if (created)
            {
                return(source);
            }

            if (config == null)
            {
                config = new DbConfig(true);
            }

#pragma warning disable 618
            return(DbAccessLayer.ReflectionPropertySet(config, source, type, eagerReader, new DbAccessLayer.ReflectionSetCacheModel(), accessType));

#pragma warning restore 618
        }