kekyo / DupeNukem

WebView attachable full-duplex asynchronous interoperable independent messaging library between .NET and JavaScript.
Apache License 2.0
18 stars 0 forks source link

Add automatic marshaler for .NET methods #2

Closed kekyo closed 2 years ago

kekyo commented 2 years ago

Currently, we have to register manually on .NET side methods.

So, there is an idea for:

public sealed class Foo
{
    public Task<int> Add(int a, int b) => Task.FromResult(a + b);
    public Task<int> Sub(int a, int b) => Task.FromResult(a - b);
}

var foo = new Foo();

messenger = new Messenger();

// Current strategy:
messenger.RegisterFunc<int, int, int>(foo.Add);
messenger.RegisterFunc<int, int, int>(foo.Sub);

// Automatic interpretation for declared methods:
messenger.RegisterObject(foo);
kekyo commented 2 years ago

Implemented RegisterObject feature on 22b80c286cd4b3afa515e7380dbc816a6d701d20 .