Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Improve Installing Extensions docs #2673

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions doc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,47 @@ var builder = this.CreateBuilder(args)
);
```

Add a `protected` property named Host of type `IHost` to your App.xaml.cs file:

```csharp
protected IHost? Host { get; private set; }
```

After creating the `builder`, initialize the `Host` by building it:

```csharp
Host = builder.Build();
```

### Step 3: Use the Builder to Create the Main Window

Finally, instead of directly creating an instance of a `Window` using `MainWindow = new Window()`, use the `builder` to set up the main window:

```csharp
MainWindow = builder.Window;
```diff
-MainWindow = new Window();

var builder = this.CreateBuilder(args)
.Configure(host => host
// Configure the host builder
);

+MainWindow = builder.Window;

Host = builder.Build();

if (MainWindow.Content is not Frame rootFrame)
{
rootFrame = new Frame();
MainWindow.Content = rootFrame;
}

if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(MainPage), args.Arguments);
}

MainWindow.Activate();
```

> [!IMPORTANT]
> Be sure to remove any other code that sets `MainWindow` or `Window.Current` to prevent conflicts in your application.
2 changes: 2 additions & 0 deletions doc/Learn/Authentication/AuthenticationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ There are two aspects to the Authentication extensions:

`Authentication` is provided as an Uno Feature. To enable `Authentication` support in your application, add `Authentication` to the `<UnoFeatures>` property in the Class Library (.csproj) file. In case you are using Msal Authentication add `AuthenticationMsal`, or `AuthenticationOidc` for Oidc Authentication.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Configuration/ConfigurationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This feature uses [Microsoft.Extensions.Configuration](https://www.nuget.org/pac
`Configuration` is provided as an Uno Feature. To enable `Configuration` support in your application, add `Configuration` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Hosting/HostingOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ uid: Uno.Extensions.Hosting.Overview

Hosting is provided as an Uno Feature. To enable `Hosting` support in your application, add `Hosting` to the `<UnoFeatures>` property in the Class Library (.csproj) file. For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

[!include[getting-help](../includes/getting-help.md)]
Expand Down
21 changes: 20 additions & 1 deletion doc/Learn/Hosting/HowTo-HostingSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,24 @@ uid: Uno.Extensions.Hosting.HowToHostingSetup
}
```

### 3. Build the IHost
### 3. Set Up the Main Window with the Builder

* Replace `MainWindow = new Window()` or any `MainWindow` assignment with the `builder` approach:

```cs
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
var appBuilder = this.CreateBuilder(args)
.Configure(host => {
// Configure the host builder
});

MainWindow = builder.Window;
...
}
```

### 4. Build the IHost

* Finally, build the host and assign it to the `Host` property:

Expand All @@ -55,6 +72,8 @@ uid: Uno.Extensions.Hosting.HowToHostingSetup
// Configure the host builder
});

MainWindow = builder.Window;

Host = appBuilder.Build();
...
}
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Http/HttpOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ For additional documentation on HTTP requests, read the references listed at the

`Http` is provided as an Uno Feature. To enable `Http` support in your application, add `Http` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Localization/LocalizationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ It uses [Microsoft.Extensions.Localization](https://www.nuget.org/packages/Micro

`Localization` is provided as an Uno Feature. To enable `Localization` support in your application, add `Localization` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Logging/LoggingOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ It uses [Microsoft.Extensions.Logging](https://www.nuget.org/packages/Microsoft.
`Logging` is provided as an Uno Feature. To enable `Logging` support in your application, add `Logging` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Navigation/NavigationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Navigation needs to encompass a range of UI concepts:

`Navigation` is provided as an Uno Feature. To enable `Navigation` support in your application, add `Navigation` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Serialization/SerializationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ uid: Uno.Extensions.Serialization.Overview

`Serialization` is provided as an Uno Feature. To enable `Serialization` support in your application, add `Serialization` to the `<UnoFeatures>` property in the Class Library (.csproj) file.

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
Expand Down
2 changes: 2 additions & 0 deletions doc/Learn/Storage/StorageOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Uno.Extensions.Storage facilitate local data storage across multiple platforms,
</UnoFeatures>
```

[!include[existing-app](../includes/existing-app.md)]

[!include[single-project](../includes/single-project.md)]

For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.
2 changes: 2 additions & 0 deletions doc/Learn/Validation/ValidationOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ protected override void OnLaunched(LaunchActivatedEventArgs e){
...
```

[!include[existing-app](../includes/existing-app.md)]

By default, enabling validation will register the default `Validator` type with the DI container. This class implements `IValidator` and provides functionality to execute validation rules on validatable entities.

## Using the validation service
Expand Down
8 changes: 8 additions & 0 deletions doc/Learn/includes/existing-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
uid: Uno.Extensions.ExistingApp
---

<!-- markdownlint-disable MD041 -->

> [!IMPORTANT]
> If your project doesn't have any of the Uno.Extension features set up yet, check out our [Installing Extensions in an existing project](xref:Uno.Extensions.HowToGettingStarted#installing-extensions-in-an-existing-project) docs to ensure you have all the necessary setup details.
Loading