SpawnDev.BlazorJS.Photino
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SpawnDev.BlazorJS.Photino --version 1.0.1
NuGet\Install-Package SpawnDev.BlazorJS.Photino -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpawnDev.BlazorJS.Photino" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpawnDev.BlazorJS.Photino" Version="1.0.1" />
<PackageReference Include="SpawnDev.BlazorJS.Photino" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpawnDev.BlazorJS.Photino --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SpawnDev.BlazorJS.Photino, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SpawnDev.BlazorJS.Photino@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpawnDev.BlazorJS.Photino&version=1.0.1
#tool nuget:?package=SpawnDev.BlazorJS.Photino&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SpawnDev.BlazorJS.Photino
SpawnDev.BlazorJS.Photino provides tools for 2 way interop, similar to SignalR, between the native Photino app and Blazor WebAssembly apps running in PhotinoWindow instances.
Photino.Net app
Program.cs
// Create RemoteServiceProviderBuilder
var appBuilder = PhotinoBlazorWASMAppBuilder.CreateDefault(args);
// Blazor WebAssembly instances can call these services using expressions or
// an interface DispatchProxy provided by the PhotinoAppDispatcher service
// Singleton services are shared with all windows
// Scoped services are per-window
// Transient are per call
// The demo uses this service via an interface DispatchProxy
appBuilder.Services.AddSingleton<IConsoleLogger, ConsoleLogger>();
// build
var app = appBuilder.Build();
/// <summary>
/// If true, closing the main window will hide it instead of closing it.<br/>
/// This allows the app to stay alive until all windows are closed.<br/>
/// NOTE: Only supported when PhotinoWindow.IsWindowsPlatform == true<br/>
/// Default: false
/// </summary>
app.IndependentWindows = false;
/// <summary>
/// If true the app will not exit when there are no windows except invisible MainWindow.<br/>
/// Setting this to true is useful for a system tray icon that can be used to create a new window or show the main one.<br/>
/// NOTE: Only supported when PhotinoWindow.IsWindowsPlatform == true<br/>
/// Default: false
/// </summary>
app.InvisibleKeepAlive = false;
#if DEBUG
// Set the Url where the Blazor WebAssembly dev server is hosting when DEBUG
// if not set, the app's "wwwroot/index.html" path will be used.
// In production a release build of your Blazor WASM app could be served from there.
app.SetAppBaseUri("https://localhost:7174/");
#endif
// Start app. Show main window
app.Run();
Blazor WebAssembly app
Program.cs
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// BlazorJSRuntime (PhotinoAppDispatcher dependency)
builder.Services.AddBlazorJSRuntime();
// PhotinoAppDispatcher lets Blazor WASM call into the Photino hosting app (if available) using:
// Expressions:
// var result = await PhotinoAppDispatcher.Run<TService, TResult>(service => service.SomeMethod(someVariable1, someVariable2));
// - or -
// Interface DispatchProxy:
// var service = PhotinoAppDispatcher.GetService<TService>() where TService : interface
// var result = await service.SomeMethod(someVariable1, someVariable2);
// - or -
// Register Photino host app service interface DispatchProxy and use as a normal service
// (See IConsoleLogger below)
builder.Services.AddSingleton<PhotinoAppDispatcher>();
// This adds IConsoleLogger provided by PhotinoAppDispatcher which will relay all
// async method calls to the Photino app instance via an interface DispatchProxy
builder.Services.AddSingleton(sp => sp.GetPhotinoAppService<IConsoleLogger>());
// Start
await builder.Build().BlazorJSRunAsync();
Example usage:
Connected to Photino app services: @PhotinoAppDispatcher.IsReady
<br />
<button disabled="@(!PhotinoAppDispatcher.IsReady)" class="btn btn-primary" @onclick="OpenWindow">Open Window</button>
<button disabled="@(!PhotinoAppDispatcher.IsReady)" class="btn btn-primary" @onclick="CloseThisWindow">Close this window</button>
@code {
[Inject]
PhotinoAppDispatcher PhotinoAppDispatcher { get; set; } = default!;
[Inject]
IConsoleLogger ConsoleLogger { get; set; } = default!;
private async Task OpenWindow()
{
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window being opened by " + PhotinoAppDispatcher.WindowId);
// call PhotinoBlazorWASMApp.OpenWindow() in the Photino host app on the PhotinoBlazorWASMApp service
var windowId = await PhotinoAppDispatcher.Run<PhotinoBlazorWASMApp, string>(s => s.OpenWindow());
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window opened: " + windowId);
}
private async Task CloseThisWindow()
{
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window closing: " + PhotinoAppDispatcher.WindowId);
// call PhotinoBlazorWASMWindow.Close() in the Photino host app on this window's PhotinoBlazorWASMWindow instance
await PhotinoAppDispatcher.Run<PhotinoBlazorWASMWindow>(s => s.Close());
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 8.0.19)
- Photino.NET (>= 3.2.3)
- SpawnDev.BlazorJS.WebWorkers (>= 2.23.0)
- System.Text.Json (>= 8.0.6)
-
net9.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 9.0.8)
- Photino.NET (>= 3.2.3)
- SpawnDev.BlazorJS.WebWorkers (>= 2.23.0)
- System.Text.Json (>= 9.0.8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SpawnDev.BlazorJS.Photino:
| Package | Downloads |
|---|---|
|
SpawnDev.BlazorJS.Photino.App
Blazor WebAssembly in Photino. Use this package in the Photino.Net app project. |
GitHub repositories
This package is not used by any popular GitHub repositories.