예제 #1
0
        static void Main(string[] args)
        {
            var myObject = new MyClass();

            // this creates a dynamic assembly 'Spring.Proxy'
            var factory = new ProxyFactory(myObject);

            factory.AddAdvice(new LogCallInterceptor());
            var myProxy = (IMyInterface)factory.GetProxy();

            myProxy.DoSomething();

            Console.WriteLine(Assembly.GetAssembly(myProxy.GetType()).FullName);
            Console.WriteLine();

            // this creates a dynamic assembly 'Spring.Proxy'
            var myObject2 = new MyClass2();
            var factory2  = new ProxyFactory(myObject2);

            factory2.AddAdvice(new LogCallInterceptor());
            factory2.ProxyTargetType = true;
            var myProxy2 = (MyClass2)factory2.GetProxy();

            myProxy2.DoSomething();
            Console.WriteLine(Assembly.GetAssembly(myProxy2.GetType()).FullName);

            Console.WriteLine();

            // this creates a dynamic assembly for the xml serializer (the strnge assembly name from question?)
            var s = new XmlSerializer(typeof(MyClass));

            s.Serialize(Console.Out, myObject);
            Console.WriteLine();

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var myObject = new MyClass();

            // this creates a dynamic assembly 'Spring.Proxy'
            var factory = new ProxyFactory(myObject);
            factory.AddAdvice(new LogCallInterceptor());
            var myProxy = (IMyInterface)factory.GetProxy();
            myProxy.DoSomething();

            Console.WriteLine(Assembly.GetAssembly(myProxy.GetType()).FullName);
            Console.WriteLine();

            // this creates a dynamic assembly 'Spring.Proxy'
            var myObject2 = new MyClass2();
            var factory2 = new ProxyFactory(myObject2);
            factory2.AddAdvice(new LogCallInterceptor());
            factory2.ProxyTargetType = true;
            var myProxy2 = (MyClass2)factory2.GetProxy();
            myProxy2.DoSomething();
            Console.WriteLine(Assembly.GetAssembly(myProxy2.GetType()).FullName);

            Console.WriteLine();

            // this creates a dynamic assembly for the xml serializer (the strnge assembly name from question?)
            var s = new XmlSerializer(typeof(MyClass));
            s.Serialize(Console.Out, myObject);
            Console.WriteLine();

            Console.ReadLine();
        }