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]); }
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]); }
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]); }
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(); }