-
Notifications
You must be signed in to change notification settings - Fork 2k
/
SiloBuilderReminderExtensions.cs
61 lines (57 loc) · 3.14 KB
/
SiloBuilderReminderExtensions.cs
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
57
58
59
60
61
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.Hosting;
using Orleans.Runtime.ReminderService;
namespace Orleans.Hosting
{
/// <summary>
/// Silo host builder extensions.
/// </summary>
public static class SiloBuilderReminderExtensions
{
/// <summary>Adds reminder storage using ADO.NET. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.</summary>
/// <param name="builder">The builder.</param>
/// <param name="configureOptions">Configuration delegate.</param>
/// <returns>The provided <see cref="ISiloBuilder"/>, for chaining.</returns>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static ISiloBuilder UseAdoNetReminderService(
this ISiloBuilder builder,
Action<AdoNetReminderTableOptions> configureOptions)
{
return builder.UseAdoNetReminderService(ob => ob.Configure(configureOptions));
}
/// <summary>Adds reminder storage using ADO.NET. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.</summary>
/// <param name="builder">The builder.</param>
/// <param name="configureOptions">Configuration delegate.</param>
/// <returns>The provided <see cref="ISiloBuilder"/>, for chaining.</returns>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static ISiloBuilder UseAdoNetReminderService(
this ISiloBuilder builder,
Action<OptionsBuilder<AdoNetReminderTableOptions>> configureOptions)
{
return builder.ConfigureServices(services => services.UseAdoNetReminderService(configureOptions));
}
/// <summary>Adds reminder storage using ADO.NET. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.</summary>
/// <param name="services">The service collection.</param>
/// <param name="configureOptions">Configuration delegate.</param>
/// <returns>The provided <see cref="IServiceCollection"/>, for chaining.</returns>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static IServiceCollection UseAdoNetReminderService(this IServiceCollection services, Action<OptionsBuilder<AdoNetReminderTableOptions>> configureOptions)
{
services.AddReminders();
services.AddSingleton<IReminderTable, AdoNetReminderTable>();
services.ConfigureFormatter<AdoNetReminderTableOptions>();
services.AddSingleton<IConfigurationValidator, AdoNetReminderTableOptionsValidator>();
configureOptions(services.AddOptions<AdoNetReminderTableOptions>());
return services;
}
}
}