void Start() { // Debug.Log("sdfffffffffffff"); LuaEnv luaenv = new LuaEnv(); luaenv.DoString(script); CalcNew calc_new = luaenv.Global.GetInPath <CalcNew>("Calc.New"); luaenv.Global.Set("InvokeLua", this); ICalc calc = calc_new(10000, "hi", "john"); //constructor Debug.Log("sum(*10) =" + calc.Add(1, 2)); calc.Mult = 100; Debug.Log("sum(*100)=" + calc.Add(1, 2)); int abc = luaenv.Global.GetInPath <int>("A.B.C"); Debug.Log("---------" + abc); luaenv.Global.SetInPath <int>("A.B.C", 1000); int abc1 = luaenv.Global.GetInPath <int>("A.B.C"); Debug.Log("------1---" + abc1); luaenv.Global.Set("tt", 12377); int t; luaenv.Global.Get("tt", out t); Debug.Log("---tt---" + t); luaenv.Dispose(); }
void Test(LuaEnv luaenv) { luaenv.DoString(script); CalcNew calc_new = luaenv.Global.GetInPath <CalcNew>("Calc.New"); ICalc calc = calc_new(10, "hi", "john"); //constructor Debug.Log("sum(*10) =" + calc.Add(1, 2)); calc.Mult = 100; Debug.Log("sum(*100)=" + calc.Add(1, 2)); }
// Use this for initialization void Start() { LuaEnv luaenv = new LuaEnv(); luaenv.DoString(script); CalcNew calc_new = luaenv.Global.GetInPath <CalcNew>("Calc.New"); ICalc calc = calc_new(10, 23, "hi", "john"); //constructor Debug.Log("sum(*10) =" + calc.Add(1, 2)); calc.Mult = 100; Debug.Log("sum(*100)=" + calc.Add(1, 2)); luaenv.Dispose(); }
void Test(LuaEnv luaenv) { luaenv.DoString(script); //声明代理对象,把它和lua Calc的New方法绑定,mult=mult;...=args CalcNew calc_new = luaenv.Global.GetInPath <CalcNew>("Calc.New"); //通过委托传参给New,打印“hi","john",calc_mt的元表,Mult设置为10 ICalc calc = calc_new(10, "hi", "john"); //constructor //调用元表的add方法,calc作为接口可以使用add和mult属性方法,this.Mult=10(通过元表设置) //local calc_mt,定义了Calc元表的__index,查找不到add方法,自动执行了__index Debug.Log("sum(*10) =" + calc.Add(1, 2)); //通过接口get set方法,改变元表Mult calc.Mult = 100; Debug.Log("sum(*100)=" + calc.Add(1, 2)); }
public void TestFactoryBuild() { ICalc c = _k.Lookup <ICalc>("sdCalc"); Assert.AreEqual(16, (c as SingleDigitCalc).Mode); Assert.AreEqual(3, c.Add(10, 25)); }
public void TestLookupInterfaceBuild() { ICalc c = _k.Lookup <ICalc>(); Assert.AreEqual(10, c.Add(4, 6)); _k.TearDown(c); }
public string Add(string lhs, string rhs) { int l = int.Parse(lhs); int r = int.Parse(rhs); return(_c.Add(l, r).ToString()); }
public IHttpActionResult Get(int id) { var res1 = _calc.Add(id, id); var res2 = _calc2.Add(id, id); //If InRequestScope works as expected, all ICalc instances here will be the same object, with the same ID (==1). //But in fact, in unit test, when using the Self Hosting option, the result is 1 + 2 + 3 == 6 var res = _calc.Id + _calc2.Id; return(Ok(res)); }
static void Main(string[] args) { ICalc calc2 = ProxyFactory.CreateProxy <ICalc>(typeof(Calculater)); calc2.Add(2, 3); calc2.Divide(6, 3); calc2.Divide(6, 0); Console.ReadKey(true); }
public IActionResult Index() { log_.Info("executing Home/Index..."); var c = calc_.Add(1, 1); ViewBag.LastInfo = log_.GetLastInfo(); return(View()); }
void Test(LuaEnv luaEnv) { luaEnv.DoString(luaScript.text); CalcNew calc_new = luaEnv.Global.GetInPath <CalcNew>("Calc.New"); ICalc calc = calc_new(10, "hi", "john"); Debug.Log("sum(*10) = " + calc.Add(1, 2)); calc.Mult = 100; Debug.Log("sum(*100) = " + calc.Add(1, 2)); Debug.Log("list[0]=" + calc[0]); Debug.Log("list[1]=" + calc[1]); calc.PropertyChanged += Notify; calc[1] = "dddd"; Debug.Log("List[1]=" + calc[1]); calc.PropertyChanged -= Notify; calc[1] = "eeee"; Debug.Log("List[1]=" + calc[1]); }
void Test() { XLuaEnv.DoString(script); CalcNew calc_new = XLuaEnv.gtable.GetInPath <CalcNew>("Calc.New"); ICalc calc = calc_new(10, "hi", "john"); //constructor Debug.Log("sum(*10) =" + calc.Add(1, 2)); calc.Mult = 100; Debug.Log("sum(*100)=" + calc.Add(1, 2)); Debug.Log("list[0]=" + calc[0]); Debug.Log("list[1]=" + calc[1]); calc.PropertyChanged += Notify; calc[1] = "dddd"; Debug.Log("list[1]=" + calc[1]); calc.PropertyChanged -= Notify; calc[1] = "eeee"; Debug.Log("list[1]=" + calc[1]); }
private void button3_Click(object sender, EventArgs e) { ICalc calc = client.serviceClientHandler .GetServiceProxy <ICalc>("calc", textBox2.Text); var result = calc.Add(1, 2); Console.WriteLine(result); //client.SendAsync("test"); //client.SendAsync(DateTime.Now); //client.SendAsync(Guid.NewGuid()); }
static void Main(string[] args) { ICalc calc2 = ProxyFactory.CreateProxy <ICalc>(typeof(Calculater)); calc2.Add(2, 3); calc2.Divide(6, 3); User model = new User(); model.S = "asdasd"; model.I = 12; List <User> models = new List <User>(); models.Add(model); calc2.TestModel(model, models); Console.ReadKey(true); }
static void Main(string[] args) { if (int.TryParse(Console.ReadLine(), out int a) && int.TryParse(Console.ReadLine(), out int b)) { ICalc calc = Assembly.Load("DLL").CreateInstance("DLL.XgHaoAddMethod") as ICalc; Console.WriteLine($"结果是:{calc.Add(a, b)}"); } else { Console.WriteLine("请输入数字"); } Console.ReadLine(); }
private async void button1_Click(object sender, EventArgs e) { ICalc calc = serviceHandler.GetServiceProxy <ICalc>("calc", userId); var result = await Task.Factory.StartNew(() => { return(calc.Add(1, 2)); }); label1.Text = result + ""; //var result = await serviceHandler // .InvokeTaskAsync(Guid.NewGuid(), user, "calc", "Add", 1, 2); //var result2 = await serviceHandler // .InvokeTaskAsync(Guid.NewGuid(), user, "calc", "Add", 4, 6); //if (result.Success) { // label1.Text = result.ReturnValue + ""; //} else { // label1.Text = result.Message; //} }
static void Main(string[] args) { int[] myIntArray = new int[3]; Console.WriteLine("Watson come here I need you..."); //stvara http kanal i registrira ga //koristi ulaz 0 HttpChannel chan = new HttpChannel(0); ChannelServices.RegisterChannel(chan, false); FileStream fileStream = new FileStream("calculatorSoap.txt", FileMode.Open); SoapFormatter soapFormatter = new SoapFormatter(); try { ICalc calc = (ICalc)soapFormatter.Deserialize(fileStream); //koristi sucelje za pozivanje metoda double sum = calc.Add(3.0, 4.0); double difference = calc.Sub(3, 4); double product = calc.Mult(3, 4); double quotient = calc.Div(3, 4); //ispisuje rezultate Console.WriteLine("3 + 4 = {0}", sum); Console.WriteLine("3 - 4 = {0}", difference); Console.WriteLine("3 * 4 = {0}", product); Console.WriteLine("3 / 4 = {0}", quotient); } catch (Exception ex) { Console.WriteLine("Exception caught: {0}", ex.Message); } }
public void TestDefaultCalc() { ICalc c = _k.Lookup <ICalc>("dCalc"); Assert.AreEqual(8, c.Add(4, 3)); }
public void SuperClassMethod() { _calc.Add(1, 2); }
public void TestActivatorBuild() { ICalc c = _k.Lookup <ICalc>("c"); Assert.AreEqual(30, c.Add(10, 20)); }
public void TestOverloadMethodBuild() { ICalc c = _k.Lookup <ICalc>("sdCalc"); Assert.AreEqual(3, c.Add(7, 6)); }