public void Test4() { var proxier = new Proxier <TestOverride>(); var func = proxier.GetCreator <TestOverride>(); var testAbstact = func(); Assert.Equal(11, testAbstact.Get("0")); }
public void Test6() { var proxier = new Proxier <TestVirtual2>(); var func = proxier.GetCreator <TestVirtual2>(); var testAbstact = func(); Assert.Equal(11, testAbstact.Get("0")); }
public void Test2() { var proxier = new Proxier <TestInterface1>(); var func = proxier.GetCreator <TestInterface1>(); var testAbstact = func(); Assert.Equal(0, testAbstact.GetInfo1("0")); }
public void Test1() { var proxier = new Proxier <TestAbstact>(); var func = proxier.GetCreator <TestAbstact>(); TestAbstact testAbstact = func(); Assert.Equal(0, testAbstact.Get("0")); }
public async void Test7() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestTaskAbstract>(); var func = proxier.GetDefaultCreator <TestTaskAbstract>(); var testAbstact = func(); Assert.Equal(0, await testAbstact.Get("0")); }
public void Test6() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestVirtual2>(); var func = proxier.GetDefaultCreator <TestVirtual2>(); var testAbstact = func(); Assert.Equal(11, testAbstact.Get("0")); }
public void Test5() { var proxier = new Proxier <TestVirtual2>(); proxier["Get"] = "return value.Length+5;"; var func = proxier.GetCreator <TestVirtual2>(); var testAbstact = func(); Assert.Equal(6, testAbstact.Get("0")); }
public void Test3() { var proxier = new Proxier <TestInterface2>(); proxier["GetInfo2"] = "return value.Length;"; var func = proxier.GetCreator <TestInterface2>(); var testAbstact = func(); Assert.Equal(1, testAbstact.GetInfo2("0")); }
public void Test() { var proxier = new Proxier <TestAbstact>(); proxier["Get"] = "return value.Length;"; var func = proxier.GetCreator <TestAbstact>(); TestAbstact testAbstact = func(); Assert.Equal(1, testAbstact.Get("1")); }
public void Test5() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestVirtual2>(); proxier["Get"] = "return value.Length+5;"; var func = proxier.GetDefaultCreator <TestVirtual2>(); var testAbstact = func(); Assert.Equal(6, testAbstact.Get("0")); }
public void Test3() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestInterface2>(); proxier["GetInfo2"] = "return value.Length;"; var func = proxier.GetCreator(); var testAbstact = func(); Assert.Equal(1, testAbstact.GetInfo2("0")); }
public void Test2() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier(); proxier.Implement(typeof(TestInterface1)); var func = proxier.GetDefaultCreator <TestInterface1>(); var testAbstact = func(); Assert.Equal(0, testAbstact.GetInfo1("0")); }
public void Test() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestAbstact>(); proxier["Get"] = "return value.Length;"; var func = proxier.GetDefaultCreator <TestAbstact>(); TestAbstact testAbstact = func(); Assert.Equal(1, testAbstact.Get("1")); }
static void Main(string[] args) { //准备委托 TestProxy test = new TestProxy(); Func <int, string> nameFunc = test.Abcdefg; Func <string, int> ageFunc = item => item.Length; Func <string> toStringFunc = () => "重写已重载的方法!"; Action action = () => { Console.WriteLine("复用此函数!"); }; //创建联合接口代理 var proxier = new Proxier <MyAbstract, MyInterface1, MyInterface2>(); proxier["GetName"] = nameFunc; //proxier["GetAge"] = ageFunc; proxier.SetMethod("GetAge", "return age.Length;"); proxier["Show"] = action; proxier["ToString"] = toStringFunc; proxier["Show2"] = action; //获取接口实例委托 var func = proxier.GetDefaultCreator <MyInterface1>(); //创建接口实例 MyInterface1 interface1 = func(); Console.WriteLine(interface1.GetName(100)); //获取接口实例委托 var func2 = proxier.GetDefaultCreator <MyInterface2>(); //创建接口实例 MyInterface2 interface2 = func2(); Console.WriteLine(interface2.GetAge("abcdefg")); //获取接口实例委托 var func3 = proxier.GetDefaultCreator <MyAbstract>(); //创建接口实例 MyAbstract interface3 = func3(); interface3.Show(); interface3.Show2(); Console.WriteLine(interface3.ToString()); Console.ReadKey(); }
public void Test9() { NatashaInitializer.InitializeAndPreheating(); var proxier = new Proxier <TestAbstact>(); proxier.ClassBuilder.Ctor(ctor => ctor .Public() .Param <int>("value") .Body("_value = value;") ); proxier.ClassBuilder.PrivateReadonlyField <int>("_value"); proxier["Get"] = "return _value;"; var func = proxier.GetCreator <int>(); TestAbstact testAbstact = func(10); Assert.Equal(10, testAbstact.Get("1")); }
static OriginTest() { Func <string, int> action = item => item.Length + 1; //创建联合接口代理 var proxier = new Proxier <TestInterface>(); //proxier.UseSingleton(); proxier["Get"] = "return value.Length;"; //proxier["Get"] = action; _func = proxier.GetDefaultCreator <TestInterface>(); _instance = _func(); for (int i = 0; i < 10000000; i++) { _func(); } int value = _instance.Get("jaja"); var result = new TestModel(); value = result.Get("jaja"); }