private async void Int_Click(object sender, RoutedEventArgs e)
        {
            ExecuteSample executeSample = new ExecuteSample();
            int           sum           = await executeSample.Sum();

            Console.WriteLine(sum);
        }
Example #2
0
        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()}");
        }
Example #3
0
        private async void IntButton_Click(object sender, RoutedEventArgs e)
        {
            ExecuteSample executeSample = new ExecuteSample();
            int           sum           = await executeSample.ReturnIntAsync(IntBox.Text);

            IntResultLabel.Content = sum;
        }
Example #4
0
        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}";
        }
Example #5
0
        private async void CodeButton_Click(object sender, RoutedEventArgs e)
        {
            ExecuteSample executeSample = new ExecuteSample();

            CodeResultLabel.Content = await executeSample.EvaluateScriptAsync(CodeBox.Text);
        }