-
Notifications
You must be signed in to change notification settings - Fork 10
Configuring WPF → Web API → In Memory
Watch the configuration video here.
In this scenario, the WPF client consumes business services that are injected with data proxies that use HTTP (via HttpClient) to communicate with the Web API application. In turn, the Web API application uses business services that are injected with data proxies that communicate with in-memory data stores.
To configure the WPF application to use business services that are injected with HTTP data proxies, locate the MainWindow_Loaded
event handler in the MainWindow class and ensure the following line exists:
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
ConfigureHttpClientUsage();
}
An important thing to note is that the configuration code in ConfigureHttpClientUsage()
uses two business services that can be referred to as client service proxy classes. Let's take a look at the code:
The classes highlighted in red represent client service proxy classes. These classes inherit from other service classes and override command methods to bypass any command logic to simply marshal calls to the data proxy. To learn more about the necessity of client service proxies, see using client service proxies.
The next step is to configure the Web API project. The Web API project uses dynamic dependency injection to create business services and data proxies that will be injected into the API controllers. To configure the Web API project to consume in-memory data proxies, open the DependencyInjection.config file.
Notice that there are two configuration sections for data proxies; one for Entity Framework and one for In-Memory, respectively. Simply ensure that the Entity Framework Data Proxies
section is commented out and the In Memory Data Proxies
section is uncommented.
To run the application, set the WPF and Web Api projects as the startup projects in the solution and run the application.