Back to Uno

Extensions

doc/articles/getting-started/wizard/includes/extensions.md

6.6-release-branch-cut7.5 KB
Original Source

The settings on the Extensions page let you configure which Uno Extensions should be added to the solution and projects generated by the wizard.

Uno Extensions is a set of Extensions that cover common essentials application core building blocks and are supported on all operating systems Uno Platform targets.
Uno.Extensions follow the Microsoft.Extensions model that creates a host environment where you can register additional dependencies. The registered dependencies are then available throughout the application via the Services (IServiceProvider) property on the IHost instance.

The available extensions are:

Dependency Injection

Dependency Injection (DI) is an Inversion of Control (IoC) technique that enables consuming classes not to worry about the management or creation of their dependencies and instead rely on a central service to provide it when needed, based on how the provider was configured.

Uno Platform brings the power of Microsoft Extensions Dependency Injection to all operating systems it targets and enhances it with additional functionality through its Uno.Extensions.DependencyInjection library. You can learn more about it in the Uno.Extensions.DependencyInjection overview.

This is included by default in the recommended preset, but not in the blank preset.

[!NOTE] Some other features (e.g. Configuration, Http, Authentication as well as others) depend on DI and will be disabled if DI is not enabled.

dotnetcli
dotnet new unoapp -di

Configuration

This extension provides a way to load application configuration data from and to various sources using the Options Pattern. This is included by default in the recommended preset, but not in the blank preset.

Refer to the Uno Configuration documentation for more information.

dotnetcli
dotnet new unoapp -config

HTTP

Uno.Extensions.Http allows for the registration of API endpoints as multiple typed HttpClient instances. In this centralized location for accessing web resources, the lifecycle of the corresponding HttpMessageHandler objects is managed. Added clients can optionally be configured to use the platform-native handler. Additional functionality is provided to clear cookies or log diagnostic messages in responses. This library uses Microsoft.Extensions.Http for any HTTP-related work. This is included by default in the recommended preset, but not in the blank preset.

For more documentation on HTTP requests, read the documentation.

Refer to the documentation to learn how to use it in an Uno Platform app.

dotnetcli
dotnet new unoapp -http

You have three levels of HTTP support to choose from:

  • Basic

Wires up UseHttp() so you can register your own HttpClient‐backed endpoints and handlers for native HTTP clients, cookies, diagnostics, etc.

bash
dotnet new unoapp -http basic
  • Refit

Includes the Refit extension so you can create a strongly-typed REST Client for an API and register it via .AddRefitClient<TInterface>.

bash
 dotnet new unoapp -http refit

See How-To: Create a Strongly-Typed REST client for an API for details.

  • Kiota

Includes the Kiota extension so you can generate a C# client from an OpenAPI/Swagger spec and wire it up with .AddKiotaClient<TClient>.

bash
dotnet new unoapp -http kiota

See How-To: Create and register a Kiota client for an API for details.

Localization

The Localization extension is responsible for managing globalization in your app.
This enables keeping all translations of your app in a single place and enables the user to easily switch the UI language.

The generated app contains resw files, which are used to define the application strings. The supported languages are configured in appsettings.json. To learn how to switch the UI culture, refer to the localization tutorial.

The default settings come with the following pre-set languages: English (en), Spanish (es), French (fr), and Portuguese - Brazil (pt-BR).

Uno.Extensions.Localization expands Microsoft.Extensions.Localization to all OSs supported by Uno Platform.

This is included by default in the recommended preset, but not in the blank preset.

Read the full Localization documentation or learn more about Globalization.

dotnetcli
dotnet new unoapp -loc

Navigation

  • Regions

    Navigation is an integral part of any app and for that, Uno Platform has developed a navigation system that is registered and served using DI and is fully integrated with the navigation-specific UI controls out there, such as Frame, NavigationView, and TabBar.

    It is a region-based navigation. A Region is the abstraction of the view responsible for handling navigation. Regions are structured into a logical hierarchical representation that shadows the navigation-aware controls in the visual hierarchy. The hierarchy allows navigation requests to be propagated up to the parent and down to child regions as required.
    This library is also responsible for showing pop-ups, flyouts, dialogs, and other interactions with the user.

    This is the default navigation in the recommended preset.

    Learn more about Uno's Navigation library.

    dotnetcli
    dotnet new unoapp -nav regions
    
  • Blank

    Provides the default WinUI frame navigation. This is the default navigation in the blank preset.

    dotnetcli
    dotnet new unoapp -nav blank
    

Logging

Logging is a crucial component in an app that enables the developer to emit log messages whenever an important action or execution is taken by the app. This then lets you trace back any errors or issues that may arise in the future. There are several Logging tools out there, with one of the most common of them being Microsoft.Extensions.Logging.

Uno Platform provides its Uno.Extensions.Logging to bring Logging to all platforms it supports.

Uno.Extensions.Logging is covered in more detail in the Logging documentation.

  • Console

    Generates an app configured to write debug-level logging information to the Console. This is the default logging in the blank preset.

    dotnetcli
    dotnet new unoapp -log none
    
  • Default

    Generates an app that uses Dependency Injection to configure logging that writes output to Console. This is the default logging for the recommended preset.

    dotnetcli
    dotnet new unoapp -log default
    
  • Serilog

    Generates an app that uses Dependency Injection to configure logging with Serilog.

    dotnetcli
    dotnet new unoapp -log serilog
    

Refer to the Logging documentation for more information.