-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathContractSettings.cs
More file actions
47 lines (39 loc) · 1.64 KB
/
ContractSettings.cs
File metadata and controls
47 lines (39 loc) · 1.64 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
namespace UiPath.Ipc;
using System;
public sealed class ContractSettings
{
public TaskScheduler? Scheduler { get; set; }
public BeforeCallHandler? BeforeIncomingCall { get; set; }
internal ServiceFactory Service { get; }
public Func<CallInfo?, Exception, Exception>? OnError { get; set; }
internal Type ContractType => Service.Type;
internal object? ServiceInstance => Service.MaybeGetInstance();
internal IServiceProvider? ServiceProvider => Service.MaybeGetServiceProvider();
public ContractSettings(Type contractType, object? serviceInstance = null) : this(
serviceInstance is not null
? new ServiceFactory.Instance()
{
Type = contractType ?? throw new ArgumentNullException(nameof(contractType)),
ServiceInstance = serviceInstance
}
: new ServiceFactory.Deferred()
{
Type = contractType ?? throw new ArgumentNullException(nameof(contractType)),
})
{ }
public ContractSettings(Type contractType, IServiceProvider serviceProvider) : this(
new ServiceFactory.Injected()
{
Type = contractType ?? throw new ArgumentNullException(nameof(contractType)),
ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider))
})
{ }
private ContractSettings(ServiceFactory service) => Service = service;
internal ContractSettings(ContractSettings other)
{
Scheduler = other.Scheduler;
BeforeIncomingCall = other.BeforeIncomingCall;
Service = other.Service;
OnError = other.OnError;
}
}