Xui.Core.DI

Assembly: Xui.Core · C# declarations · Assembly overview

Types

enum ColorScheme

Whether the current effective appearance is light or dark.

public enum ColorScheme
{
    Light,
    Dark,
}

ColorScheme.Dark

Dark

Dark appearance — light text on dark backgrounds.

ColorScheme.Light

Light

Light appearance — dark text on light backgrounds.

enum DeviceFormFactor

The physical form factor of the device.

public enum DeviceFormFactor
{
    Desktop,
    Mobile,
    Tablet,
}

DeviceFormFactor.Desktop

Desktop

Desktop or laptop computer.

DeviceFormFactor.Mobile

Mobile

Handheld phone.

DeviceFormFactor.Tablet

Tablet

Tablet device.

enum DevicePlatform

The operating system platform.

public enum DevicePlatform
{
    Windows,
    MacOS,
    Browser,
    iOS,
    Android,
}

DevicePlatform.Android

Android

Google Android.

DevicePlatform.Browser

Browser

Web browser (WASM).

DevicePlatform.MacOS

MacOS

Apple macOS.

DevicePlatform.Windows

Windows

Microsoft Windows.

DevicePlatform.iOS

iOS

Apple iOS.

interface IDeviceInfo

Provides information about the current device, platform, and user preferences. Resolved via this.GetService<IDeviceInfo>() from any Xui.Core.UI.View. The emulator replaces this with a mock to simulate phone or tablet form factors.

public interface IDeviceInfo
{
    event Action? Changed;
    DevicePlatform Platform { get; }

    DeviceFormFactor FormFactor { get; }

    PointerModel PointerModel { get; }

    nfloat AccessibilityFontScale { get; }

    bool PrefersReducedMotion { get; }

    bool PrefersHighContrast { get; }

    ColorScheme ColorScheme { get; }
}

NFloat IDeviceInfo.AccessibilityFontScale

nfloat AccessibilityFontScale { get; }

Accessibility font scale multiplier (1.0 = default).

event Action? IDeviceInfo.Changed

event Action? Changed;

Raised on the UI thread when a device or system preference exposed by this service changes.

ColorScheme IDeviceInfo.ColorScheme

ColorScheme ColorScheme { get; }

Light or dark appearance preference.

DeviceFormFactor IDeviceInfo.FormFactor

DeviceFormFactor FormFactor { get; }

Gets the form factor of the current device.

DevicePlatform IDeviceInfo.Platform

DevicePlatform Platform { get; }

Gets the operating system the app is running on.

PointerModel IDeviceInfo.PointerModel

PointerModel PointerModel { get; }

Gets the primary pointing device available to the user.

bool IDeviceInfo.PrefersHighContrast

bool PrefersHighContrast { get; }

True if the user has requested high-contrast mode.

bool IDeviceInfo.PrefersReducedMotion

bool PrefersReducedMotion { get; }

True if the user has requested reduced motion.

enum PointerModel

The primary pointing device available to the user.

public enum PointerModel
{
    Touch,
    Stylus,
    Mouse,
    Controller,
    Eye,
}

PointerModel.Controller

Controller

D-pad or game controller.

PointerModel.Eye

Eye

Eye-tracking or gaze-based input.

PointerModel.Mouse

Mouse

Mouse or trackpad.

PointerModel.Stylus

Stylus

Stylus or pen.

PointerModel.Touch

Touch

Finger on a touch screen.

class ServiceProviderExtensions

Generic convenience wrappers over System.IServiceProvider, mirroring the shape of Microsoft.Extensions.DependencyInjection without pulling in that package.

public static class ServiceProviderExtensions
{
    public static T? GetService<T>(this IServiceProvider provider);
    public static T GetRequiredService<T>(this IServiceProvider provider);
}

T ServiceProviderExtensions.GetRequiredService<T>(IServiceProvider provider)

public static T GetRequiredService<T>(this IServiceProvider provider);

Returns the service of type T. Throws System.InvalidOperationException if the service is not found.

T? ServiceProviderExtensions.GetService<T>(IServiceProvider provider)

public static T? GetService<T>(this IServiceProvider provider);

Returns the service of type T, or null if no such service is registered.