示例#1
0
        static void Main(string[] args)
        {
            #region 简单工厂模式

            Console.WriteLine("当前模式:{0}", "简单工厂模式");

            Test2.Test();

            Console.WriteLine("--------------------------------------------");

            #endregion

            #region 工厂方法模式

            Console.WriteLine("当前模式:{0}", "工厂方法模式");

            Test3.Test();

            Console.WriteLine("--------------------------------------------");

            #endregion

            #region 抽象工厂模式



            #endregion



            Console.ReadKey();
        }
示例#2
0
        public static void Main()
        {
            Test0.Test();
            Console.WriteLine();
            Test1.Test();
            Console.WriteLine();
            Test2.Test();
            Console.WriteLine();
            Test3.Test();
            Console.WriteLine();

            Console.ReadKey();
        }
示例#3
0
        static void Main()
        {
            Test0.Test(new string[0]);
            Console.WriteLine();
            Test1.Test(new string[0]);
            Console.WriteLine();
            Test2.Test();
            Console.WriteLine();
            Test3.Test();
            Console.WriteLine();
            Test4.Test();
            Console.WriteLine();

            Console.ReadKey();
        }
示例#4
0
        public void CreateProxy(int value)
        {
            var watch = new Stopwatch();
            var watchNativeImplementedInterceptorWatch = new Stopwatch();
            var watchNative = new Stopwatch();
            var nproxy      = new Stopwatch();
            var result      = ProxyFactory.Default.CreateProxy <Test1, Test3, Interceptor>();
            var native      = new TestXY();
            var nativeImplementedInterceptor = new Test3();
            int total = value;

#if (!NETCOREAPP2_0)
            var proxy = (Test1) new NProxy.Core.ProxyFactory().GetProxyTemplate(typeof(Test1), new[] { typeof(Test1) }).CreateProxy(new NewProxy());
#endif
            while (total-- > 0)
            {
                watch.Start();
                result.X();
                watch.Stop();

                watchNative.Start();
                native.Test("1", null, 1, 1L, 122, .0d);
                watchNative.Stop();

                watchNativeImplementedInterceptorWatch.Start();
                nativeImplementedInterceptor.Test("1", null, 1, 1L, 122, .0d);
                watchNativeImplementedInterceptorWatch.Stop();

#if (!NETCOREAPP2_0)
                nproxy.Start();
                proxy.X();
                nproxy.Stop();
#endif
            }
            Console.WriteLine($"{watch.Elapsed} Proxy takes for {value} calls");
            Console.WriteLine($"{watchNative.Elapsed} Native takes for {value} calls");
            Console.WriteLine($"{watchNativeImplementedInterceptorWatch.Elapsed} Native Use Proxy Call takes for {value} calls");
#if (!NETCOREAPP1_1)
            Console.WriteLine($"{nproxy.Elapsed} nproxy takes for {value} calls");
#endif
        }
示例#5
0
 public static int Main()
 {
     Test1.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test1 OK");
     }
     Test2.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test2 OK");
     }
     Test3.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test3 OK");
     }
     Test4.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test4 OK");
     }
     Test5.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test5 OK");
     }
     Test6.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test6 OK");
     }
     Test7.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test7 OK");
     }
     Test8.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test8 OK");
     }
     Test9.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test9 OK");
     }
     Test10.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test10 OK");
     }
     Test11.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test11 OK");
     }
     Test12.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test12 OK");
     }
     Test13.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test13 OK");
     }
     Test14.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test14 OK");
     }
     Test15.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test15 OK");
     }
     Test16.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test16 OK");
     }
     Test17.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test17 OK");
     }
     Test18.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test18 OK");
     }
     Test19.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test19 OK");
     }
     Test20.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test20 OK");
     }
     Test21.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test21 OK");
     }
     Test22.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test22 OK");
     }
     Test23.Test();
     if (Utils.failures == 0)
     {
         Console.WriteLine("Test23 OK");
     }
     if (Utils.failures > 0)
     {
         return(101);
     }
     else
     {
         Console.WriteLine("PASS");
         return(100);
     }
 }