コード例 #1
0
        public void CanInstantiateClassWithDefaultConstructor()
        {
            var activator = new DynamicDelegateActivator(typeof(Test), Test.DefaultConstructorInfo);

            var instance = activator.CreateInstance(null);

            Assert.IsNotNull(instance);
            Assert.IsInstanceOf<Test>(instance);
        }
コード例 #2
0
        public DynamicDelegateContainerActivator(
            Type type,
            ConstructorInfo constructor, 
            ArgumentCollection constructorArguments)
        {
            _constructor = constructor;
            _constructorArguments = constructorArguments;

            _activator = new DynamicDelegateActivator(type, constructor);
        }
コード例 #3
0
        public void CanInstantiateNonDefaultConstructor()
        {
            var activator = new DynamicDelegateActivator(typeof(Test), Test.OtherConstructorInfo);

            var instance = activator.CreateInstance(new object[] { "name", Int32.MaxValue }) as Test;

            Assert.IsNotNull(instance);

            Assert.AreEqual("name", instance.Arg1);
            Assert.AreEqual(Int32.MaxValue, instance.Arg2);
        }