forked from dotnet/dotnet-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionsServiceCollectionExtensions.cs
48 lines (42 loc) · 1.91 KB
/
ActionsServiceCollectionExtensions.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Diagnostics.Monitoring.TestCommon.Options;
using Microsoft.Diagnostics.Tools.Monitor;
using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options;
using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Diagnostics.Monitoring.TestCommon
{
internal static class ActionsServiceCollectionExtensions
{
public static IServiceCollection RegisterTestAction(this IServiceCollection services, CallbackActionService callback)
{
services.AddSingleton(callback);
services.RegisterCollectionRuleAction<CallbackActionFactory, BaseRecordOptions, CallbackActionDescriptor>();
return services;
}
public static IServiceCollection RegisterDelayedTestAction(this IServiceCollection services, CallbackActionService callback)
{
services.AddSingleton(callback);
services.RegisterCollectionRuleAction<DelayedCallbackActionFactory, BaseRecordOptions, DelayedCallbackActionDescriptor>();
return services;
}
public static CollectionRuleOptions AddPassThroughAction(this CollectionRuleOptions options, string name,
string input1, string input2, string input3)
{
return options.AddAction(
nameof(PassThroughAction),
actionOptions =>
{
PassThroughOptions settings = new PassThroughOptions()
{
Input1 = input1,
Input2 = input2,
Input3 = input3
};
actionOptions.Name = name;
actionOptions.Settings = settings;
});
}
}
}