Skip to content

Commit

Permalink
Merge pull request #4 from AlonTalmi/SupportForValueTypesFuncRegistra…
Browse files Browse the repository at this point in the history
…tion

Support for Value Types delegate registration
  • Loading branch information
AlonTalmi authored Nov 14, 2023
2 parents 8a1d59d + a4c069c commit ab184ad
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,15 @@ public static RegistrationBuilder Register<TInterface>(
this IContainerBuilder builder,
Func<IObjectResolver, TInterface> implementationConfiguration,
Lifetime lifetime)
where TInterface : class
=> builder.Register(new FuncRegistrationBuilder(implementationConfiguration, typeof(TInterface), lifetime));
=> builder.Register(new FuncRegistrationBuilder(resolver => implementationConfiguration(resolver), typeof(TInterface), lifetime));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RegistrationBuilder Register<TInterface>(
this IContainerBuilder builder,
Func<IObjectResolver, TInterface> implementationConfiguration,
Lifetime lifetime,
Action<TInterface, IObjectResolver> callback)
where TInterface : class
=> builder.Register(new FuncRegistrationBuilderWithCallback(implementationConfiguration, typeof(TInterface), lifetime, (instance, resolver) => callback((TInterface)instance, resolver)));
=> builder.Register(new FuncRegistrationBuilderWithCallback(resolver => implementationConfiguration(resolver), typeof(TInterface), lifetime, (instance, resolver) => callback((TInterface)instance, resolver)));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RegistrationBuilder RegisterInstance<TInterface>(
Expand Down

0 comments on commit ab184ad

Please sign in to comment.