-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
ServiceDiscoveryFacade.cs
39 lines (32 loc) · 1.09 KB
/
ServiceDiscoveryFacade.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
using System.Reflection;
using JetBrains.Annotations;
namespace JsonApiDotNetCore.Configuration;
/// <summary>
/// Provides auto-discovery by scanning assemblies for resources and related injectables.
/// </summary>
[PublicAPI]
public sealed class ServiceDiscoveryFacade
{
private readonly ResourceDescriptorAssemblyCache _assemblyCache;
internal ServiceDiscoveryFacade(ResourceDescriptorAssemblyCache assemblyCache)
{
ArgumentGuard.NotNull(assemblyCache);
_assemblyCache = assemblyCache;
}
/// <summary>
/// Includes the calling assembly for auto-discovery of resources and related injectables.
/// </summary>
public ServiceDiscoveryFacade AddCurrentAssembly()
{
return AddAssembly(Assembly.GetCallingAssembly());
}
/// <summary>
/// Includes the specified assembly for auto-discovery of resources and related injectables.
/// </summary>
public ServiceDiscoveryFacade AddAssembly(Assembly assembly)
{
ArgumentGuard.NotNull(assembly);
_assemblyCache.RegisterAssembly(assembly);
return this;
}
}