public void Overrides_Proxy_Override_Twice()
        {
            ProxyFactory factory  = new ProxyFactory();
            MyService2   service2 = new MyService2();

            factory.AddProxyOverride <IMyService>(service2);
            factory.AddProxyOverride <IMyService>(service2);

            var proxy = factory.Proxy <IMyService>();

            Assert.AreEqual("hello", proxy.TestMe("hi"));
        }
        public void MessageFilter_Override()
        {
            var factory = new ProxyFactory();

            factory.AddProxyOverride <IMessageFilterService2, MessageFilterService2_2>(new MessageFilterService2_2());
            var proxy = factory.Proxy <IMessageFilterService2>();

            Assert.AreEqual("bye", proxy.TestMe("hi"));
        }
Exemple #3
0
        public static void AddOverride <I, J>()
            where I : class
            where J : I, new()
        {
            if (_factory == null)
            {
                _factory = new ProxyFactory();
            }

            _factory.AddProxyOverride <I, J>(new J());
        }
        public void Overrides_Proxy_OverrideNested_Override()
        {
            ProxyFactory factory = new ProxyFactory();

            var proxy           = factory.Proxy <IMyService>();
            var overrideService = new MyNestedService2();

            factory.AddProxyOverride <IMyServiceNested>(overrideService);

            Assert.AreEqual("goodbye", proxy.Nested());
        }
        public void Overrides_Override()
        {
            ProxyFactory factory  = new ProxyFactory();
            MyService2   service2 = new MyService2();

            factory.AddProxyOverride <IMyService, MyService2>(service2);

            factory.Call <IMyService>(proxy =>
            {
                Assert.AreEqual("hello", proxy.TestMe("hi"));
            });
        }
        //[TestMethod]
        public void Performance_NativeThruProxy()
        {
            var factory = new ProxyFactory();

            factory.LogEnabled = false;
            factory.AddProxyOverride <IMyService, MyService>(new MyService());

            Stopwatch sw = new Stopwatch();

            sw.Reset();
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                Assert.AreEqual("hi", factory.Proxy <IMyService>().TestMe("hi"));
            }
            sw.Stop();
            Trace.WriteLine("Native thru Proxy time = " + sw.ElapsedMilliseconds);
        }
Exemple #7
0
 public static void OverrideProxy <TContract, TImpl>(TImpl impl)
     where TContract : class
     where TImpl : TContract
 {
     Factory.AddProxyOverride <TContract>(impl);
 }