예제 #1
0
 public static object Get(string key, Type type)
 {
     if (!container.ContainsKey(key))
     {
         lock (container)
             if (!container.ContainsKey(key))
             {
                 //获取得对象经过了AOP的代理
                 container[key] = AOPBuider.Buider(type);
             }
     }
     return(container[key]);
 }
예제 #2
0
        public static object Get(Type type)
        {
            var key = type.FullName;

            if (!container.ContainsKey(key))
            {
                lock (container)
                    if (!container.ContainsKey(key))
                    {
                        //获取得对象经过了AOP的代理
                        container[key] = AOPBuider.Buider(type);
                    }
            }
            return(container[key]);
        }
예제 #3
0
        public static SingletonType Get <SingletonType>() where SingletonType : new()
        {
            Type type = typeof(SingletonType);
            var  key  = type.FullName;

            if (!container.ContainsKey(key))
            {
                lock (container)
                    if (!container.ContainsKey(key))
                    {
                        //获取得对象经过了AOP的代理
                        container[key] = AOPBuider.Buider <SingletonType>();
                    }
            }
            return((SingletonType)container[key]);
        }
예제 #4
0
파일: AOPTest.cs 프로젝트: MochouHu/Mochou
        public static void Test(string[] args)
        {
            RealClass proxy = AOPBuider.Buider <RealClass>();

            proxy.Test();
            proxy.Test2();

            proxy.AAA = "aaa";
            Console.WriteLine("调用AAA:" + proxy.AAA);
            proxy.BBB = "bbb";
            Console.WriteLine("调用BBB:" + proxy.BBB);

            Console.ReadKey();

            RealClass proxy2 = AOPBuider.Buider <RealClass>();

            proxy2.Test();

            RealClass2 proxy21 = AOPBuider.Buider <RealClass2>();

            proxy2.Test();
            Console.ReadKey();
        }