コード例 #1
0
 public void DefaultConstructor(int iterations)
 {
     for (int i = 0; i < iterations; i++)
     {
         var item = new ClassWithDefaultConstructor();
     }
 }
コード例 #2
0
 public void DefaultConstructor(int iterations)
 {
     for (int i = 0; i < iterations; i++)
     {
         ClassWithDefaultConstructor item = FastActivator <ClassWithDefaultConstructor> .Create();
     }
 }
コード例 #3
0
ファイル: NewActivatorRunner.cs プロジェクト: daffers/Magnum
		public void DefaultConstructor(int iterations)
		{
			for (int i = 0; i < iterations; i++)
			{
				var item = new ClassWithDefaultConstructor();
			}
		}
コード例 #4
0
        public void An_object_not_matching_the_constraint_should_throw_an_exception()
        {
            var argument = new ClassWithDefaultConstructor();

            Assert.Throws <FastActivatorException>(() =>
            {
                var obj = FastActivator.Create(typeof(ClassWithAConstrainedGenericArgument <,>), argument);
            });
        }
コード例 #5
0
ファイル: Performance_Specs.cs プロジェクト: jgsteeler/Magnum
        public void Using_new_with_no_arguments()
        {
            Trace.WriteLine("Using new()");

            for (int i = 0; i < Iterations; i++)
            {
                var item = new ClassWithDefaultConstructor();
            }
        }
コード例 #6
0
ファイル: Performance_Specs.cs プロジェクト: jgsteeler/Magnum
        public void Using_object_generator_with_no_arguments()
        {
            Trace.WriteLine("Using FastActivator()");

            for (int i = 0; i < Iterations; i++)
            {
                ClassWithDefaultConstructor item = FastActivator <ClassWithDefaultConstructor> .Create();
            }
        }
コード例 #7
0
        public static void Main(string[] args)
        {
            //a class without constructors gets a default constructor from the compiler
            ClassWithoutConstructors c1 = new ClassWithoutConstructors(); //we can invoke this method even if it's not in our source code

            //we can redefine the default constructor if we want
            ClassWithDefaultConstructor c2 = new ClassWithDefaultConstructor(); //prints to the console

            //we can overload the constructors if necessary
            ClassWithOverloadedConstructors c3 = new  ClassWithOverloadedConstructors();   // first constructor (default we wrote)
            ClassWithOverloadedConstructors c4 = new  ClassWithOverloadedConstructors(10); // second constructor (with an int, that we wrote)

            ClassWithoutDefaultConstructor c5 = new ClassWithoutDefaultConstructor(5);     //we cannot make any instance unless we pass an int, because we don't have the default constructor
        }
コード例 #8
0
ファイル: GenericType_Specs.cs プロジェクト: daffers/Magnum
		public void An_object_not_matching_the_constraint_should_throw_an_exception()
		{
			var argument = new ClassWithDefaultConstructor();

			Assert.Throws<FastActivatorException>(() =>
				{
					var obj = FastActivator.Create(typeof(ClassWithAConstrainedGenericArgument<,>), argument);
				});
		}
コード例 #9
0
ファイル: Performance_Specs.cs プロジェクト: KevM/Magnum
        public void Using_new_with_no_arguments()
        {
            Trace.WriteLine("Using new()");

            for (int i = 0; i < Iterations; i++)
            {
                var item = new ClassWithDefaultConstructor();
            }
        }
 internal ClassWithInternalConstructorAndOneClassParameter(ClassWithDefaultConstructor c)
 {
 }