public ClassA1(bool p1, char p2, string p3, int p4, float p5, double p6,
                decimal p7, DateTime p8, IClassB p9, IClassC p10, IClassD p11, object p12,
                IEnumerable <object> p13, byte p14, short p15, long p16, EnumForA p17,
                bool?p18, bool?p19, int?p20, int?p21, decimal?p22, decimal?p23)
 {
     this.P1  = p1;
     this.P2  = p2;
     this.P3  = p3;
     this.P4  = p4;
     this.P5  = p5;
     this.P6  = p6;
     this.P7  = p7;
     this.P8  = p8;
     this.P9  = p9;
     this.P10 = p10;
     this.P11 = p11;
     this.P12 = p12;
     this.P13 = p13;
     this.P14 = p14;
     this.P15 = p15;
     this.P16 = p16;
     this.P17 = p17;
     this.P18 = p18;
     this.P19 = p19;
     this.P20 = p20;
     this.P21 = p21;
     this.P22 = p22;
     this.P23 = p23;
 }
            public void GivenBuiltProxyWithTargetInterface_WhenMemberIsCalled_ThenMemberIsIntercepted()
            {
                var subjectBuilder = new DynamicProxyBuilder();

                // Given
                var cTarget1 = new ClassC { CP1 = 5 };
                var cTarget2 = new ClassC { CP1 = 15 };
                var interceptor1 = new Inteceptor1();
                IClassC proxy = subjectBuilder
                    .ForInterface<IClassC>()
                    .WithTargetInterface(cTarget1)
                    .AddInterceptor(interceptor1)
                    .Build();

                // When
                interceptor1.ChangeProxyTarget(cTarget2);
                interceptor1.ChangeInvocationTarget(cTarget2);

                int aValue = 0;
                proxy.CMethod(() => aValue = 10);
                var ret1_CP1 = proxy.CP1;
                proxy.CP1 = 17;
                var ret2_CP1 = proxy.CP1;

                // Then
                Assert.IsTrue(ProxyUtil.IsProxy(proxy), "object is not a proxy");
                Assert.AreEqual(4, interceptor1.InterceptReceivedCall);
                Assert.AreEqual(10, aValue);
                Assert.AreEqual(15, ret1_CP1);
                Assert.AreEqual(17, ret2_CP1);
            }
Beispiel #3
0
            public void GivenBuiltProxyWithTarget_WhenMemberIsCalled_ThenMemberIsIntercepted()
            {
                var subjectBuilder = new DynamicProxyBuilder();

                // Given
                var cTarget = new ClassC {
                    CP1 = 5
                };
                var     aInterceptor = new InterceptorA();
                var     bInterceptor = new InterceptorB();
                IClassC proxy        = subjectBuilder
                                       .ForInterface <IClassC>()
                                       .WithTarget(cTarget)
                                       .AddInterceptors(aInterceptor, bInterceptor)
                                       .Build();

                // When
                int aValue = 0;

                proxy.CMethod(() => aValue = 10);
                var ret1_CP1 = proxy.CP1;

                proxy.CP1 = 7;
                var ret2_CP1 = proxy.CP1;

                // Then
                Assert.IsTrue(ProxyUtil.IsProxy(proxy), "object is not a proxy");
                Assert.AreEqual(4, aInterceptor.InterceptReceivedCall);
                Assert.AreEqual(4, bInterceptor.InterceptReceivedCall);
                Assert.AreEqual(10, aValue);
                Assert.AreEqual(5, ret1_CP1);
                Assert.AreEqual(7, ret2_CP1);
            }
Beispiel #4
0
            public void GivenBuiltProxyWithoutTarget_WhenMemberIsCalled_ThenMemberIsIntercepted()
            {
                var subjectBuilder = new DynamicProxyBuilder();

                // Given
                var     testInterceptor1 = new TestInterceptor3(() => 1);
                var     testInterceptor2 = new TestInterceptor4(() => 2);
                IClassC proxy            = subjectBuilder
                                           .ForInterface <IClassC>()
                                           .WithoutTraget()
                                           .AddInterceptors(testInterceptor1, testInterceptor2)
                                           .Build();

                // When
                int aValue = 0;

                proxy.CMethod(() => aValue = 10); // the test method does have target and action is not called
                var retValue = proxy.CP1;         // the first interceptor in the chain determine the return value

                // Then
                Assert.IsTrue(ProxyUtil.IsProxy(proxy), "object is not a proxy");
                Assert.AreEqual(2, testInterceptor1.InterceptReceivedCall);
                Assert.AreEqual(2, testInterceptor2.InterceptReceivedCall);
                Assert.AreEqual(0, aValue);
                Assert.AreEqual(1, retValue);
            }
Beispiel #5
0
        static void Main(string[] args)
        {
            Container container = new Container();

            container.RegisterType <IClassA, ClassA>();
            container.RegisterType <IClassB, ClassB>();
            container.RegisterType <IClassC, ClassC>();

            IClassA A = container.Resolve <IClassA>();

            IClassB B = container.Resolve <IClassB>();

            IClassC C = container.Resolve <IClassC>();

            C.ConsoleLog();

            Console.ReadLine();
        }
Beispiel #6
0
 public ClassB(IClassC classc)
 {
     Console.WriteLine("ClassB");
     Console.WriteLine("  ClassC: {0}", classc.GetType());
 }
Beispiel #7
0
 public ClassA(IClassB classb, IClassC classc)
 {
     Console.WriteLine("ClassA");
     Console.WriteLine("  ClassB: {0}", classb.GetType());
     Console.WriteLine("  ClassC: {0}", classc.GetType());
 }
Beispiel #8
0
 public ClassE(IClassA a, IClassB b, IClassC c)
 {
     _a = a;
     _b = b;
     _c = c;
 }
Beispiel #9
0
 public ContextC(IClassA a, IClassB b, IClassC c)
 {
     _a = a;
     _b = b;
     _c = c;
 }
Beispiel #10
0
 public ClassB(IClassC classC)
 {
     _classC = classC;
 }