private async void Int_Click(object sender, RoutedEventArgs e) { ExecuteSample executeSample = new ExecuteSample(); int sum = await executeSample.Sum(); Console.WriteLine(sum); }
async void ExecuteSampleCallingMethod() { // Operation which returns integers ExecuteSample executeSample = new ExecuteSample(); int sum = await executeSample.ReturnIntAsync(); Console.WriteLine(sum); // Operation which change variable provided by calling application string initValue = "default Value"; Console.WriteLine($"For Globals.SomeValue is default:{initValue}"); string newValue = await executeSample.UseGlobalDataInScriptAsync(initValue, "PersonInGlobals.Name = \"Person Name changed inside script\"; SomeVariable = \"new value\";" + "PersonInGlobals.Items.Add(new Item(){ItemName =\"Item Name\"});"); Console.WriteLine($"Inserted script changed value to: {newValue}"); // Runs given code string code = @"int Add(int x, int y) { return x+y; } Add(1, 4)"; var result = await executeSample.EvaluateScriptAsync(code); Console.WriteLine($"Result of code is: {result.ToString()}"); }
private async void IntButton_Click(object sender, RoutedEventArgs e) { ExecuteSample executeSample = new ExecuteSample(); int sum = await executeSample.ReturnIntAsync(IntBox.Text); IntResultLabel.Content = sum; }
private async void GlobalsButton_Click(object sender, RoutedEventArgs e) { ExecuteSample executeSample = new ExecuteSample(); string initValue = "default Value"; string newValue = await executeSample.UseGlobalDataInScriptAsync(initValue); GlobalsResultLabel.Content = $"Inserted script changed value to: {newValue}"; }
private async void CodeButton_Click(object sender, RoutedEventArgs e) { ExecuteSample executeSample = new ExecuteSample(); CodeResultLabel.Content = await executeSample.EvaluateScriptAsync(CodeBox.Text); }