Control WPF c# application via script

726 views Asked by At

I'm analysing if it is possible to control my application with scripts/macros.

My application is a WPF application written in c#/VS2015 and I'm trying to do the following (pseudo code)

public interface IExposedTasks
{
    IEnumerable<Customer> Customers {get; }
    void ShowSum(int sum);
}

public static class Host : IExposedTasks 
{
    public IEnumerable<string> Customers { ... }

    public void ShowSum(int sum)
    {
        MessageBox.Show("Sum: " + sum.ToString());
    }
}

...

public void ExecuteScript(string script)
{
    // execute script 
}

The script should be able to access all data from IExposedTasks and do something like:

var sum = 0;

foreach(var customer in Host.Customers) 
{
    sum += customer.Value;
}

Host.ShowSum(sum);

The language of the scripts could be in c#, JavaScript or VB.

I have tried to do this with Cs-Script, but it does not seem to work on Win10/VS2015.

COM is not an alternative.

Can anyone point me into the right direction?

Thanks in advance!

0

There are 0 answers