# Xui.Core.DI

Assembly: **Xui.Core** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`enum ColorScheme`](#api-8b61de4e9da7c5f8)
- [`enum DeviceFormFactor`](#api-cc52ba9dce2235e7)
- [`enum DevicePlatform`](#api-05c924078501c311)
- [`interface IDeviceInfo`](#api-04ce8bffb2aea2af)
- [`enum PointerModel`](#api-0741ee6da14f943b)
- [`class ServiceProviderExtensions`](#api-14a5607f7e04d6f9)

<a id="api-8b61de4e9da7c5f8"></a>

## `enum ColorScheme`

Whether the current effective appearance is light or dark.

```csharp
public enum ColorScheme
{
    Light,
    Dark,
}
```

<a id="api-498e08fc8f463e40"></a>

### [`ColorScheme.Dark`](#api-498e08fc8f463e40)


```csharp
Dark
```

Dark appearance — light text on dark backgrounds.

<a id="api-a64cca7e3c211cfa"></a>

### [`ColorScheme.Light`](#api-a64cca7e3c211cfa)


```csharp
Light
```

Light appearance — dark text on light backgrounds.


<a id="api-cc52ba9dce2235e7"></a>

## `enum DeviceFormFactor`

The physical form factor of the device.

```csharp
public enum DeviceFormFactor
{
    Desktop,
    Mobile,
    Tablet,
}
```

<a id="api-169fcc8f0e58ce0c"></a>

### [`DeviceFormFactor.Desktop`](#api-169fcc8f0e58ce0c)


```csharp
Desktop
```

Desktop or laptop computer.

<a id="api-1bf5fd4e4bc48418"></a>

### [`DeviceFormFactor.Mobile`](#api-1bf5fd4e4bc48418)


```csharp
Mobile
```

Handheld phone.

<a id="api-a4588553ce1b1f07"></a>

### [`DeviceFormFactor.Tablet`](#api-a4588553ce1b1f07)


```csharp
Tablet
```

Tablet device.


<a id="api-05c924078501c311"></a>

## `enum DevicePlatform`

The operating system platform.

```csharp
public enum DevicePlatform
{
    Windows,
    MacOS,
    Browser,
    iOS,
    Android,
}
```

<a id="api-e346d0c67ce53c9e"></a>

### [`DevicePlatform.Android`](#api-e346d0c67ce53c9e)


```csharp
Android
```

Google Android.

<a id="api-b8902e9e768cf943"></a>

### [`DevicePlatform.Browser`](#api-b8902e9e768cf943)


```csharp
Browser
```

Web browser (WASM).

<a id="api-18111c71d0e5fdb7"></a>

### [`DevicePlatform.MacOS`](#api-18111c71d0e5fdb7)


```csharp
MacOS
```

Apple macOS.

<a id="api-ef1fca835513e2cb"></a>

### [`DevicePlatform.Windows`](#api-ef1fca835513e2cb)


```csharp
Windows
```

Microsoft Windows.

<a id="api-0104bbfe9ea55e42"></a>

### [`DevicePlatform.iOS`](#api-0104bbfe9ea55e42)


```csharp
iOS
```

Apple iOS.


<a id="api-04ce8bffb2aea2af"></a>

## `interface IDeviceInfo`

Provides information about the current device, platform, and user preferences. Resolved via `this.GetService<IDeviceInfo>()` from any [`Xui.Core.UI.View`](../xui-core-ui/index.md#api-0389f82d4babca03). The emulator replaces this with a mock to simulate phone or tablet form factors.

```csharp
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; }
}
```

<a id="api-7e81dd2b6198bb48"></a>

### [`NFloat IDeviceInfo.AccessibilityFontScale`](#api-7e81dd2b6198bb48)


```csharp
nfloat AccessibilityFontScale { get; }
```

Accessibility font scale multiplier (1.0 = default).

<a id="api-7fbabb2dce6e076a"></a>

### [`event Action? IDeviceInfo.Changed`](#api-7fbabb2dce6e076a)


```csharp
event Action? Changed;
```

Raised on the UI thread when a device or system preference exposed by this service changes.

<a id="api-beccd55451304a9e"></a>

### [`ColorScheme IDeviceInfo.ColorScheme`](#api-beccd55451304a9e)


```csharp
ColorScheme ColorScheme { get; }
```

Light or dark appearance preference.

<a id="api-cfae7d299685ea23"></a>

### [`DeviceFormFactor IDeviceInfo.FormFactor`](#api-cfae7d299685ea23)


```csharp
DeviceFormFactor FormFactor { get; }
```

Gets the form factor of the current device.

<a id="api-29e729df253933d1"></a>

### [`DevicePlatform IDeviceInfo.Platform`](#api-29e729df253933d1)


```csharp
DevicePlatform Platform { get; }
```

Gets the operating system the app is running on.

<a id="api-83b9d5e536778e4c"></a>

### [`PointerModel IDeviceInfo.PointerModel`](#api-83b9d5e536778e4c)


```csharp
PointerModel PointerModel { get; }
```

Gets the primary pointing device available to the user.

<a id="api-ad6a25d46c99f9d7"></a>

### [`bool IDeviceInfo.PrefersHighContrast`](#api-ad6a25d46c99f9d7)


```csharp
bool PrefersHighContrast { get; }
```

True if the user has requested high-contrast mode.

<a id="api-3670719da3e86298"></a>

### [`bool IDeviceInfo.PrefersReducedMotion`](#api-3670719da3e86298)


```csharp
bool PrefersReducedMotion { get; }
```

True if the user has requested reduced motion.


<a id="api-0741ee6da14f943b"></a>

## `enum PointerModel`

The primary pointing device available to the user.

```csharp
public enum PointerModel
{
    Touch,
    Stylus,
    Mouse,
    Controller,
    Eye,
}
```

<a id="api-5892a52b3e2b2710"></a>

### [`PointerModel.Controller`](#api-5892a52b3e2b2710)


```csharp
Controller
```

D-pad or game controller.

<a id="api-755863784eb1ea37"></a>

### [`PointerModel.Eye`](#api-755863784eb1ea37)


```csharp
Eye
```

Eye-tracking or gaze-based input.

<a id="api-66e8ef2fa5207dde"></a>

### [`PointerModel.Mouse`](#api-66e8ef2fa5207dde)


```csharp
Mouse
```

Mouse or trackpad.

<a id="api-cc738d25415684fb"></a>

### [`PointerModel.Stylus`](#api-cc738d25415684fb)


```csharp
Stylus
```

Stylus or pen.

<a id="api-5675c484d1fb92e9"></a>

### [`PointerModel.Touch`](#api-5675c484d1fb92e9)


```csharp
Touch
```

Finger on a touch screen.


<a id="api-14a5607f7e04d6f9"></a>

## `class ServiceProviderExtensions`

Generic convenience wrappers over `System.IServiceProvider`, mirroring the shape of Microsoft.Extensions.DependencyInjection without pulling in that package.

```csharp
public static class ServiceProviderExtensions
{
    public static T? GetService<T>(this IServiceProvider provider);
    public static T GetRequiredService<T>(this IServiceProvider provider);
}
```

<a id="api-01d819e49d067727"></a>

### [`T ServiceProviderExtensions.GetRequiredService<T>(IServiceProvider provider)`](#api-01d819e49d067727)


```csharp
public static T GetRequiredService<T>(this IServiceProvider provider);
```

Returns the service of type `T`. Throws `System.InvalidOperationException` if the service is not found.

<a id="api-c0b0f7ca6a3b924b"></a>

### [`T? ServiceProviderExtensions.GetService<T>(IServiceProvider provider)`](#api-c0b0f7ca6a3b924b)


```csharp
public static T? GetService<T>(this IServiceProvider provider);
```

Returns the service of type `T`, or `null` if no such service is registered.

