-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleDatabaseModelDependencyModule.cs
More file actions
56 lines (52 loc) · 2.7 KB
/
ExampleDatabaseModelDependencyModule.cs
File metadata and controls
56 lines (52 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RapidField.SolidInstruments.DataAccess.DotNetNative.Extensions;
using RapidField.SolidInstruments.Example.DatabaseModel.CommandHandlers;
using RapidField.SolidInstruments.Example.DatabaseModel.Commands;
using RapidField.SolidInstruments.InversionOfControl.DotNetNative;
using System;
using System.Collections.Generic;
namespace RapidField.SolidInstruments.Example.DatabaseModel
{
/// <summary>
/// Encapsulates configuration for Example database model dependencies.
/// </summary>
public sealed class ExampleDatabaseModelDependencyModule : DotNetNativeDependencyModule
{
/// <summary>
/// Initializes a new instance of the <see cref="ExampleDatabaseModelDependencyModule" /> class.
/// </summary>
/// <param name="applicationConfiguration">
/// Configuration information for the application.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="applicationConfiguration" /> is <see langword="null" />.
/// </exception>
public ExampleDatabaseModelDependencyModule(IConfiguration applicationConfiguration)
: base(applicationConfiguration)
{
return;
}
/// <summary>
/// Configures the module.
/// </summary>
/// <param name="configurator">
/// An object that configures containers.
/// </param>
/// <param name="applicationConfiguration">
/// Configuration information for the application.
/// </param>
protected override void Configure(ServiceCollection configurator, IConfiguration applicationConfiguration)
{
// Register unit-of-work types.
configurator.AddScoped<ExampleContext, ExampleInMemoryContext>(provider => new ExampleInMemoryContext(provider.GetService<IConfiguration>(), "Example"));
configurator.AddScoped<ExampleRepositoryFactory>();
// Register data access command handlers.
configurator.AddDataAccessCommandHandler<AddFibonacciNumberCommand, AddFibonacciNumberCommandHandler>();
configurator.AddDataAccessCommandHandler<GetFibonacciNumberValuesCommand, IEnumerable<Int64>, GetFibonacciNumberValuesCommandHandler>();
}
}
}