Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non-generic RegisterInstance overload #695

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static string[] GetAllTypeNames()
{
return new List<string> { "None" }
.Concat(TypeCache.GetTypesDerivedFrom<LifetimeScope>()
.Where(x => !x.IsAbstract)
.Select(type => type.FullName))
.ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ public static RegistrationBuilder Register<TInterface>(
Func<IObjectResolver, TInterface> implementationConfiguration,
Lifetime lifetime)
=> builder.Register(new FuncRegistrationBuilder(container => implementationConfiguration(container), typeof(TInterface), lifetime));


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RegistrationBuilder RegisterInstance(
this IContainerBuilder builder,
object instance,
Type implementationType)
=> builder.Register(new InstanceRegistrationBuilder(instance)).As(implementationType);

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