コード例 #1
0
        public void Test_GetActivator_With_Parameter_Types()
        {
            var activator1 = typeof(ParameterfulCtor).GetActivator(typeof(int), typeof(string));

            var obj = activator1(1, "1") as ParameterfulCtor;

            obj.Should().NotBeNull();
            obj.Id.Should().Be(1);

            var activator2 = ObjectActivatorBuilder.Build <ParameterfulCtor>(typeof(int), typeof(string));

            obj = activator2(2, "2");

            obj.Should().NotBeNull();
            obj.Id.Should().Be(2);
        }
コード例 #2
0
        public void Test_GetActivator()
        {
            var activator1 = typeof(ParameterlessCtor).GetActivator();

            var obj = activator1() as ParameterlessCtor;

            obj.Id   = 1;
            obj.Name = "1";

            obj.Should().NotBeNull();
            obj.Id.Should().Be(1);

            var activator2 = ObjectActivatorBuilder.Build <ParameterlessCtor>();

            obj = activator2();

            obj.Id   = 2;
            obj.Name = "2";

            obj.Should().NotBeNull();
            obj.Id.Should().Be(2);
        }