Skip to content

Commit

Permalink
ffs
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus committed Sep 7, 2023
1 parent 292756f commit bbcba24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Samples/Minimal/cs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
// 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()}, Sharp here!");
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);
// -------------------------------------------------------

// Improvised API of JavaScript frontend.
public interface IFrontend { string GetName (); }
public interface IFrontend { string GetName (); Info GetInfo(); }
// Improvised API of C# backend.
public interface IBackend { string GetName (); }
// Implementation of the backend.
class SharpBackend : IBackend { public string GetName () => "Sharp"; }
class SharpBackend : IBackend { public string GetName () => ".NET"; }
5 changes: 5 additions & 0 deletions Samples/Minimal/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import bootsharp, { Backend, Frontend } from "./cs/bin/bootsharp/bootsharp.js";

// Binding 'IFrontend.GetName' endpoint invoked in C#.
Frontend.getName = () => "Node.js";

// TODO: Checking serialization, remove later.
Frontend.getInfo = () => ({ foo: "TEST" });


// Initializing dotnet runtime and invoking entry point.
await bootsharp.boot();
// Invoking 'IBackend.GetName' C# method.
Expand Down

0 comments on commit bbcba24

Please sign in to comment.