Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus committed Sep 8, 2023
1 parent bbcba24 commit f345854
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Samples/Minimal/cs/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
// Specifying JavaScript APIs to generate bindings for.

using System.Diagnostics.CodeAnalysis;

[assembly: Bootsharp.JSImport(typeof(IFrontend))]
// Specifying C# APIs to generate bindings for.
[assembly: Bootsharp.JSExport(typeof(IBackend))]

// Using generated C# bindings to inject implementation (usually handled by DI).
_ = new Backend.JSBackend(new SharpBackend());
// Using generated JavaScript bindings to invoke 'Frontend.getName()' function.
System.Console.WriteLine($"Hello {Frontend.JSFrontend.GetName()}, .NET here!");

// -------------------------------------------------------
// TODO: Checking serialization, remove later.
System.Console.WriteLine(Frontend.JSFrontend.GetInfo().Foo);
public record Info(string Foo);
// -------------------------------------------------------

public static class Program
{
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Info))]
public static void Main ()
{
// Using generated C# bindings to inject implementation (usually handled by DI).
_ = new Backend.JSBackend(new SharpBackend());
// Using generated JavaScript bindings to invoke 'Frontend.getName()' function.
System.Console.WriteLine($"Hello {Frontend.JSFrontend.GetName()}, .NET here!");
// -------------------------------------------------------
// TODO: Checking serialization, remove later.
System.Console.WriteLine(Frontend.JSFrontend.GetInfo().Foo);
}
}

// Improvised API of JavaScript frontend.
public interface IFrontend { string GetName (); Info GetInfo(); }
// Improvised API of C# backend.
Expand Down

0 comments on commit f345854

Please sign in to comment.