public void ObjectInstantiatonTests()
        {
            int numIterations = 1000000;


            start = DateTime.Now;
            Type t = typeof(AccountCreditDao);

            for (int i = 0; i < numIterations; i++)
            {
                //ObjectUtils.IsInstantiable(t);
                IDynamicConstructor dc = DynamicConstructor.Create(t.GetConstructor(Type.EmptyTypes));
                dc.Invoke(ObjectUtils.EmptyObjects);
            }
            stop = DateTime.Now;
            double timeElapsed = Elapsed;

            PrintTest("SafeConstructor", numIterations, timeElapsed);

            start = DateTime.Now;
            for (int i = 0; i < numIterations; i++)
            {
                ObjectUtils.InstantiateType(typeof(AccountCreditDao));
            }
            stop        = DateTime.Now;
            timeElapsed = Elapsed;
            PrintTest("InstantiateType", numIterations, timeElapsed);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbProvider"/> class.
 /// </summary>
 /// <param name="dbMetadata">The db metadata.</param>
 public DbProvider(IDbMetadata dbMetadata)
 {
     this.dbMetadata   = dbMetadata;
     newCommand        = DynamicConstructor.Create(dbMetadata.CommandType.GetConstructor(Type.EmptyTypes));
     newConnection     = DynamicConstructor.Create(dbMetadata.ConnectionType.GetConstructor(Type.EmptyTypes));
     newCommandBuilder = DynamicConstructor.Create(dbMetadata.CommandBuilderType.GetConstructor(Type.EmptyTypes));
     newDataAdapter    = DynamicConstructor.Create(dbMetadata.DataAdapterType.GetConstructor(Type.EmptyTypes));
     newParameter      = DynamicConstructor.Create(dbMetadata.ParameterType.GetConstructor(Type.EmptyTypes));
 }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbProvider"/> class.
        /// </summary>
        /// <param name="dbMetadata">The db metadata.</param>
        public DbProvider(IDbMetadata dbMetadata)
        {
            this.dbMetadata = dbMetadata;
            newCommand      = DynamicConstructor.Create(dbMetadata.CommandType.GetConstructor(Type.EmptyTypes));

            // Oracle needs custom bind by name property set to true as it's false by default
            var bindByNameProperty = dbMetadata.CommandType.GetProperty("BindByName");

            if (bindByNameProperty != null && bindByNameProperty.CanWrite)
            {
                commandBindByName = DynamicProperty.Create(bindByNameProperty);
            }

            newConnection     = DynamicConstructor.Create(dbMetadata.ConnectionType.GetConstructor(Type.EmptyTypes));
            newCommandBuilder = DynamicConstructor.Create(dbMetadata.CommandBuilderType.GetConstructor(Type.EmptyTypes));
            newDataAdapter    = DynamicConstructor.Create(dbMetadata.DataAdapterType.GetConstructor(Type.EmptyTypes));
            newParameter      = DynamicConstructor.Create(dbMetadata.ParameterType.GetConstructor(Type.EmptyTypes));
        }