Core bridge service for host and platform detection.
public interface IBridge
{
Host Host { get; }
PlatformIdentity Platform { get; }
string PlatformVersion { get; }
bool IsInitialized { get; }
event EventHandler<PlatformIdentity>? PlatformChanged;
Task InitializeAsync();
}Form factor detection with optional resize listening.
public interface IBridgeFormFactor
{
FormFactorInfo FormFactor { get; }
event EventHandler<FormFactorInfo>? FormFactorChanged;
Task InitializeAsync(ResizeMode resizeMode = ResizeMode.None);
Task CreateListenerAsync();
ValueTask DisposeListenerAsync();
}Internet connectivity monitoring.
public interface IBridgeConnectivity
{
bool IsConnected { get; }
event EventHandler<bool>? ConnectionChanged;
Task InitializeAsync(ConnectivityOptions? options = null);
}System theme (light/dark mode) detection.
public interface IBridgeTheme
{
ThemeMode Theme { get; }
event EventHandler<ThemeMode>? ThemeChanged;
Task InitializeAsync();
}Safe area insets for notched/cutout devices.
public interface IBridgeSafeArea
{
SafeAreaInsets SafeArea { get; }
event EventHandler<SafeAreaInsets>? SafeAreaChanged;
Task InitializeAsync();
}public enum Host
{
Unknown,
Maui,
Blazor,
Wpf,
WinForms,
}public enum PlatformIdentity
{
Unknown,
Android,
IOS,
Windows,
Mac,
Linux,
}public enum FormFactor
{
Unknown,
Phone,
Tablet,
Desktop,
}public enum ResizeMode
{
None, // Components manage their own listeners
Global, // Single persistent shared listener
Once, // Read once, no ongoing listening
}public enum ThemeMode
{
Unknown,
Light,
Dark,
}public sealed record FormFactorInfo(FormFactor FormFactor, double Width, double Height)
{
public static FormFactorInfo Unknown();
public static FormFactorInfo Unknown(double width, double height);
}public sealed record SafeAreaInsets(double Top, double Right, double Bottom, double Left)
{
public static SafeAreaInsets Zero { get; }
public bool HasInsets { get; }
}public sealed class ConnectivityOptions
{
public int IntervalInSeconds { get; set; } = 10; // Polling interval (Blazor only)
public string TestUrl { get; set; } = "/favicon.ico"; // URL to ping (Blazor only)
}All components are in the Circuids.Bridge namespace.
| Component | RenderFragments | Context Type |
|---|---|---|
<BridgeHost> |
Maui, Blazor, Wpf, WinForms, Default |
Host |
<BridgePlatform> |
Android, IOS, Windows, Mac, Linux, Default |
PlatformIdentity |
<BridgeFormFactor> |
Phone, Tablet, Desktop, DesktopAndTablet, DesktopAndPhone, TabletAndPhone, Default |
FormFactorInfo |
<BridgeConnectivity> |
Online, Offline |
bool |
<BridgeTheme> |
Light, Dark, Default |
ThemeMode |
<BridgeSafeArea> |
— | SafeAreaInsets |
| Provider | Parameters | Description |
|---|---|---|
<BridgeProvider> |
FormFactorResizeMode, ConnectivityOptions |
Composite — initializes all services. |
<BridgeFormFactorProvider> |
Mode (ResizeMode) |
Initializes IBridgeFormFactor. |
<BridgeConnectivityProvider> |
Options (ConnectivityOptions?) |
Initializes IBridgeConnectivity. |
<BridgeThemeProvider> |
— | Initializes IBridgeTheme. |
<BridgeSafeAreaProvider> |
— | Initializes IBridgeSafeArea. |
public abstract class BridgeHostHandler<T>
{
protected BridgeHostHandler(IBridge bridge);
protected abstract T OnBlazor();
protected virtual T OnMaui() => OnBlazor();
protected virtual T OnWpf() => OnBlazor();
protected virtual T OnWinForms() => OnBlazor();
protected virtual T OnUnknown() => throw new BridgeException(...);
public T Execute();
}public abstract class BridgeHostHandler
{
protected BridgeHostHandler(IBridge bridge);
protected abstract void OnBlazor();
protected virtual void OnMaui() => OnBlazor();
protected virtual void OnWpf() => OnBlazor();
protected virtual void OnWinForms() => OnBlazor();
protected virtual void OnUnknown() => throw new BridgeException(...);
public void Execute();
}public abstract class BridgeHostHandlerAsync<T>
{
protected BridgeHostHandlerAsync(IBridge bridge);
protected abstract Task<T> OnBlazor();
protected virtual Task<T> OnMaui() => OnBlazor();
protected virtual Task<T> OnWpf() => OnBlazor();
protected virtual Task<T> OnWinForms() => OnBlazor();
protected virtual Task<T> OnUnknown() => throw new BridgeException(...);
public Task<T> ExecuteAsync();
}public abstract class BridgeHostHandlerAsync
{
protected BridgeHostHandlerAsync(IBridge bridge);
protected abstract Task OnBlazor();
protected virtual Task OnMaui() => OnBlazor();
protected virtual Task OnWpf() => OnBlazor();
protected virtual Task OnWinForms() => OnBlazor();
protected virtual Task OnUnknown() => throw new BridgeException(...);
public Task ExecuteAsync();
}public sealed class BridgeException : Exception
{
public BridgeException(string message);
public BridgeException(string message, Exception innerException);
}public static IServiceCollection AddBridgeForBlazor(this IServiceCollection services);public static IServiceCollection AddBridgeForMaui(this IServiceCollection services);