public void DefaultConstructor(int iterations) { for (int i = 0; i < iterations; i++) { var item = new ClassWithDefaultConstructor(); } }
public void DefaultConstructor(int iterations) { for (int i = 0; i < iterations; i++) { ClassWithDefaultConstructor item = FastActivator <ClassWithDefaultConstructor> .Create(); } }
public void DefaultConstructor(int iterations) { for (int i = 0; i < iterations; i++) { var item = new ClassWithDefaultConstructor(); } }
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); }); }
public void Using_new_with_no_arguments() { Trace.WriteLine("Using new()"); for (int i = 0; i < Iterations; i++) { var item = new ClassWithDefaultConstructor(); } }
public void Using_object_generator_with_no_arguments() { Trace.WriteLine("Using FastActivator()"); for (int i = 0; i < Iterations; i++) { ClassWithDefaultConstructor item = FastActivator <ClassWithDefaultConstructor> .Create(); } }
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 }
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); }); }
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) { }