forked from dotnetcore/AspectCore-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightInjectExtensions.cs
More file actions
31 lines (28 loc) · 1.03 KB
/
Copy pathLightInjectExtensions.cs
File metadata and controls
31 lines (28 loc) · 1.03 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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using LightInject;
namespace AspectCore.Extensions.LightInject
{
internal static class LightInjectExtensions
{
public static IServiceRegistry AddSingleton<T, TImpl>(this IServiceRegistry services, string name = default)
where T : class
where TImpl : class, T
{
return services.Register<T, TImpl>(name ?? string.Empty, new PerContainerLifetime());
}
public static IServiceRegistry AddSingleton<T>(this IServiceRegistry services, T instance)
where T : class
{
return services.RegisterInstance<T>(instance);
}
public static IServiceRegistry AddTransient(this IServiceRegistry services, Type service, Type impl)
{
// The default behavior in LightInject is to treat all objects as transients unless otherwise specified.
return services.Register(service, impl);
}
}
}