Skip to content

Commit baf90ee

Browse files
Refactor overloads.
1 parent 3be68c0 commit baf90ee

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

LazyProxy.Autofac/AutofacExtensions.cs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,21 @@ namespace LazyProxy.Autofac
1212
/// </summary>
1313
public static class AutofacExtensions
1414
{
15-
/// <summary>
16-
/// Is used to register interface TFrom to class TTo by creation a lazy proxy at runtime.
17-
/// The real class To will be instantiated only after first method or property execution.
18-
/// </summary>
19-
/// <param name="builder">The instance of the Autofac container builder.</param>
20-
/// <typeparam name="TFrom">The linked interface.</typeparam>
21-
/// <typeparam name="TTo">The linked class.</typeparam>
22-
/// <returns>The instance of the Autofac registration builder.</returns>
23-
public static IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrationStyle>
24-
RegisterLazy<TFrom, TTo>(this ContainerBuilder builder)
25-
where TTo : TFrom where TFrom : class =>
26-
builder.RegisterLazy(typeof(TFrom), typeof(TTo), null);
27-
2815
/// <summary>
2916
/// Is used to register interface TFrom to class TTo by creation a lazy proxy at runtime.
3017
/// The real class To will be instantiated only after first method or property execution.
3118
/// </summary>
3219
/// <param name="builder">The instance of the Autofac container builder.</param>
3320
/// <param name="name">The registration name. Null if named registration is not required.</param>
21+
/// <param name="nonLazyRegistrationMutator">A mutator allowing to change the non-lazy registration.</param>
3422
/// <typeparam name="TFrom">The linked interface.</typeparam>
3523
/// <typeparam name="TTo">The linked class.</typeparam>
3624
/// <returns>The instance of the Autofac registration builder.</returns>
3725
public static IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrationStyle>
38-
RegisterLazy<TFrom, TTo>(this ContainerBuilder builder, string name)
26+
RegisterLazy<TFrom, TTo>(this ContainerBuilder builder, string name = null,
27+
IRegistrationMutator nonLazyRegistrationMutator = null)
3928
where TTo : TFrom where TFrom : class =>
40-
builder.RegisterLazy(typeof(TFrom), typeof(TTo), name);
41-
42-
/// <summary>
43-
/// Is used to register interface TFrom to class TTo by creation a lazy proxy at runtime.
44-
/// The real class To will be instantiated only after first method execution.
45-
/// </summary>
46-
/// <param name="typeFrom">The linked interface.</param>
47-
/// <param name="typeTo">The linked class.</param>
48-
/// <param name="builder">The instance of the Autofac container builder.</param>
49-
/// <returns>The instance of the Autofac registration builder.</returns>
50-
public static IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrationStyle>
51-
RegisterLazy(this ContainerBuilder builder, Type typeFrom, Type typeTo) =>
52-
builder.RegisterLazy(typeFrom, typeTo, null);
29+
builder.RegisterLazy(typeof(TFrom), typeof(TTo), name, nonLazyRegistrationMutator);
5330

5431
/// <summary>
5532
/// Is used to register interface TFrom to class TTo by creation a lazy proxy at runtime.
@@ -62,7 +39,7 @@ public static IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrati
6239
/// <param name="nonLazyRegistrationMutator">A mutator allowing to change the non-lazy registration.</param>
6340
/// <returns>The instance of the Autofac registration builder.</returns>
6441
public static IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrationStyle>
65-
RegisterLazy(this ContainerBuilder builder, Type typeFrom, Type typeTo, string name,
42+
RegisterLazy(this ContainerBuilder builder, Type typeFrom, Type typeTo, string name = null,
6643
IRegistrationMutator nonLazyRegistrationMutator = null)
6744
{
6845
// There is no way to constraint it on the compilation step.

0 commit comments

Comments
 (0)