Skip to content

Commit 662d8e5

Browse files
Update with latest code
1 parent facf7b0 commit 662d8e5

34 files changed

+133
-131
lines changed

.openpublishing.redirection.architecture.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,10 @@
812812
{
813813
"source_path_from_root": "/docs/architecture/modernize-desktop/windows-migration.md",
814814
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-desktop-apps/Modernize-Desktop-Apps-on-Windows-with-NET.pdf"
815+
},
816+
{
817+
"source_path_from_root": "/docs/architecture/maui/configuration-management.md",
818+
"redirect_url": "/dotnet/architecture/maui/app-settings-management"
815819
}
816820
]
817821
}

docs/architecture/maui/accessing-remote-data.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: Accessing Remote Data
33
description: Communicating with Web APIs in .NET MAUI
44
author: michaelstonis
55
no-loc: [MAUI]
6-
ms.date: 07/12/2022
6+
ms.date: 05/30/2024
77
---
88

9-
# Accessing remote data
9+
# Accessing Remote Data
1010

1111
[!INCLUDE [download-alert](includes/download-alert.md)]
1212

@@ -33,11 +33,11 @@ For more information about REST, see [API design](/azure/architecture/best-pract
3333

3434
## Consuming RESTful APIs
3535

36-
The eShopOnContainers multi-platform app uses the Model-View-ViewModel (MVVM) pattern, and the model elements of the pattern represent the domain entities used in the app. The controller and repository classes in the eShopOnContainers reference application accept and return many of these model objects. Therefore, they are used as data transfer objects (DTOs) that hold all the data that is passed between the app and the containerized microservices. The main benefit of using DTOs to pass data to and receive data from a web service is that by transmitting more data in a single remote call, the app can reduce the number of remote calls that need to be made.
36+
The eShop multi-platform app uses the Model-View-ViewModel (MVVM) pattern, and the model elements of the pattern represent the domain entities used in the app. The controller and repository classes in the eShop reference application accept and return many of these model objects. Therefore, they are used as data transfer objects (DTOs) that hold all the data that is passed between the app and the containerized microservices. The main benefit of using DTOs to pass data to and receive data from a web service is that by transmitting more data in a single remote call, the app can reduce the number of remote calls that need to be made.
3737

3838
## Making web requests
3939

40-
The eShopOnContainers multi-platform app uses the `HttpClient` class to make requests over HTTP, with JSON being used as the media type. This class provides functionality for asynchronously sending HTTP requests and receiving HTTP responses from a URI identified resource. The HttpResponseMessage class represents an HTTP response message received from a REST API after an HTTP request has been made. It contains information about the response, including the status code, headers, and any body. The HttpContent class represents the HTTP body and content headers, such as Content-Type and Content-Encoding. The content can be read using any of the `ReadAs` methods, such as `ReadAsStringAsync` and `ReadAsByteArrayAsync`, depending on the format of the data.
40+
The eShop multi-platform app uses the `HttpClient` class to make requests over HTTP, with JSON being used as the media type. This class provides functionality for asynchronously sending HTTP requests and receiving HTTP responses from a URI identified resource. The HttpResponseMessage class represents an HTTP response message received from a REST API after an HTTP request has been made. It contains information about the response, including the status code, headers, and any body. The HttpContent class represents the HTTP body and content headers, such as Content-Type and Content-Encoding. The content can be read using any of the `ReadAs` methods, such as `ReadAsStringAsync` and `ReadAsByteArrayAsync`, depending on the format of the data.
4141

4242
## Making a GET request
4343

@@ -291,12 +291,12 @@ The most common form of caching is read-through caching, where an app retrieves
291291
292292
This data can be added to the cache on demand the first time it is retrieved by an app. This means that the app needs to fetch the data only once from the data store, and that subsequent access can be satisfied by using the cache.
293293

294-
Distributed applications, such as the eShopOnContainers reference application, should provide either or both of the following caches:
294+
Distributed applications, such as the eShop reference application, should provide either or both of the following caches:
295295

296296
- A shared cache, which can be accessed by multiple processes or machines.
297297
- A private cache, where data is held locally on the device running the app.
298298

299-
The eShopOnContainers multi-platform app uses a private cache, where data is held locally on the device that's running an instance of the app. For information about the cache used by the eShopOnContainers reference application, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
299+
The eShop multi-platform app uses a private cache, where data is held locally on the device that's running an instance of the app. For information about the cache used by the eShop reference application, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
300300

301301
> [!TIP]
302302
> Think of the cache as a transient data store that could disappear at any time.
@@ -318,7 +318,7 @@ It's also possible that a cache might fill up if data is allowed to remain for t
318318

319319
## Caching images
320320

321-
The eShopOnContainers multi-platform app consumes remote product images that benefit from being cached. These images are displayed by the Image control. The .NET MAUI Image control supports caching of downloaded images which has caching enabled by default, and will store the image locally for 24 hours. In addition, the expiration time can be configured with the CacheValidity property. For more information, see [Downloaded Image Caching](/dotnet/maui/user-interface/controls/image#image-caching) on the Microsoft Developer Center.
321+
The eShop multi-platform app consumes remote product images that benefit from being cached. These images are displayed by the Image control. The .NET MAUI Image control supports caching of downloaded images which has caching enabled by default, and will store the image locally for 24 hours. In addition, the expiration time can be configured with the CacheValidity property. For more information, see [Downloaded Image Caching](/dotnet/maui/user-interface/controls/image#image-caching) on the Microsoft Developer Center.
322322

323323
## Increasing resilience
324324

@@ -352,7 +352,7 @@ If a request still fails after a number of retries, it's better for the app to p
352352
353353
Use a finite number of retries, or implement the [Circuit Breaker](/azure/architecture/patterns/circuit-breaker) pattern to allow a service to recover.
354354

355-
The eShopOnContainers reference application does implement the retry pattern. For more information, including a discussion of how to combine the retry pattern with the HttpClient class, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
355+
The eShop reference application does implement the retry pattern. For more information, including a discussion of how to combine the retry pattern with the HttpClient class, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
356356

357357
For more information about the retry pattern, see the [Retry](/azure/architecture/patterns/retry) pattern on Microsoft Docs.
358358

@@ -367,7 +367,7 @@ The circuit breaker pattern can prevent an app from repeatedly trying to execute
367367
368368
A circuit breaker acts as a proxy for operations that might fail. The proxy should monitor the number of recent failures that have occurred, and use this information to decide whether to allow the operation to proceed, or to return an exception immediately.
369369

370-
The eShopOnContainers multi-platform app does not currently implement the circuit breaker pattern. However, the eShopOnContainers does. For more information, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
370+
The eShop multi-platform app does not currently implement the circuit breaker pattern. However, the eShop does. For more information, see [.NET Microservices: Architecture for Containerized .NET Applications](https://aka.ms/microservicesebook).
371371

372372
> [!TIP]
373373
> Combine the retry and circuit breaker patterns.

docs/architecture/maui/configuration-management.md renamed to docs/architecture/maui/app-settings-management.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Configuration Management
2+
title: Application Settings Management
33
description: Managing persistent configurations in .NET MAUI
44
author: michaelstonis
55
no-loc: [MAUI]
6-
ms.date: 06/28/2022
6+
ms.date: 05/30/2024
77
---
88

9-
# Configuration management
9+
# Application Settings Management
1010

1111
[!INCLUDE [download-alert](includes/download-alert.md)]
1212

@@ -18,10 +18,10 @@ User settings are the customizable settings of an app that affect the app's beha
1818

1919
## Creating a Settings Interface
2020

21-
While the preferences manager can be used directly in your application, it does come with the drawback of making your application tightly coupled to the preferences manager implementation. This coupling means that creating unit tests or extending the functionality of preferences management will be limited since your application will not have a direct way to intercept the behavior. To address this concern, an interface can be created to work as a proxy for preferences management. The interface will allow us to supply an implementation that fits our needs. For example, when writing a unit test, we may want to set specific settings, and the interface will give us an easy way to consistently set this data for the test. The following code example shows the `ISettingsService` interface in the eShopOnContainers multi-platform app:
21+
While the preferences manager can be used directly in your application, it does come with the drawback of making your application tightly coupled to the preferences manager implementation. This coupling means that creating unit tests or extending the functionality of preferences management will be limited since your application will not have a direct way to intercept the behavior. To address this concern, an interface can be created to work as a proxy for preferences management. The interface will allow us to supply an implementation that fits our needs. For example, when writing a unit test, we may want to set specific settings, and the interface will give us an easy way to consistently set this data for the test. The following code example shows the `ISettingsService` interface in the eShop multi-platform app:
2222

2323
```csharp
24-
namespace eShopOnContainers.Services.Settings;
24+
namespace eShop.Services.Settings;
2525

2626
public interface ISettingsService
2727
{
@@ -45,13 +45,13 @@ public interface ISettingsService
4545
> [!TIP]
4646
> Preferences is meant for storing relatively small data. If you need to store larger or more complex data, consider using a local database or filesystem to store the data.
4747
48-
Our application will use the `Preferences` class need to implement the `ISettingsService` interface. The code below shows how the eShopOnContainers multi-platform app's `SettingsService` implements the `AuthTokenAccess` and `UseMocks` properties:
48+
Our application will use the `Preferences` class need to implement the `ISettingsService` interface. The code below shows how the eShop multi-platform app's `SettingsService` implements the `AuthTokenAccess` and `UseMocks` properties:
4949

5050
```csharp
5151
public sealed class SettingsService : ISettingsService
5252
{
5353
private const string AccessToken = "access_token";
54-
private const string AccessTokenDefault = "";
54+
private const string AccessTokenDefault = string.Empty;
5555

5656
private const string IdUseMocks = "use_mocks";
5757
private const bool UseMocksDefault = true;
@@ -74,9 +74,9 @@ Each setting consists of a private key, a private default value, and a public pr
7474

7575
## Data binding to user settings
7676

77-
In the eShopOnContainers multi-platform app, the `SettingsView` exposes multiple settings the user can configure at runtime. These settings include allowing configuration of whether the app should retrieve data from microservices deployed as Docker containers or whether the app should retrieve data from mock services that don't require an internet connection. When retrieving data from containerized microservices, a base endpoint URL for the microservices must be specified. The image below shows the SettingsView when the user has chosen to retrieve data from containerized microservices.
77+
In the eShop multi-platform app, the `SettingsView` exposes multiple settings the user can configure at runtime. These settings include allowing configuration of whether the app should retrieve data from microservices deployed as Docker containers or whether the app should retrieve data from mock services that don't require an internet connection. When retrieving data from containerized microservices, a base endpoint URL for the microservices must be specified. The image below shows the SettingsView when the user has chosen to retrieve data from containerized microservices.
7878

79-
![User settings exposed by the eShopOnContainers multi-platform app.](./media/endpoint_settings.png)
79+
![User settings exposed by the eShop multi-platform app.](./media/endpoint_settings.png)
8080

8181
Data binding can be used to retrieve and set settings exposed by the `ISettingService` interface. This is achieved by controls on the view binding to view model properties that in turn access properties in the `ISettingService` interface and raising a property changed notification if the value has changed.
8282

0 commit comments

Comments
 (0)