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 Register(Type) #109

Merged
merged 1 commit into from
Feb 3, 2021
Merged
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
7 changes: 3 additions & 4 deletions VContainer/Assets/VContainer/Runtime/ContainerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IContainerBuilder
object ApplicationOrigin { get; set; }
bool ContainerExposed { get; set; }

RegistrationBuilder Register<T>(Lifetime lifetime);
RegistrationBuilder Register(Type type, Lifetime lifetime);
RegistrationBuilder RegisterInstance(object instance);
RegistrationBuilder Register(RegistrationBuilder registrationBuilder);

Expand Down Expand Up @@ -49,12 +49,11 @@ public class ContainerBuilder : IContainerBuilder
public object ApplicationOrigin { get; set; }
public bool ContainerExposed { get; set; }


readonly IList<RegistrationBuilder> registrationBuilders = new List<RegistrationBuilder>();
List<Action<IObjectResolver>> buildCallbacks;

public RegistrationBuilder Register<T>(Lifetime lifetime)
=> Register(new RegistrationBuilder(typeof(T), lifetime));
public RegistrationBuilder Register(Type type, Lifetime lifetime)
=> Register(new RegistrationBuilder(type, lifetime));

public RegistrationBuilder RegisterInstance(object instance)
=> Register(new RegistrationBuilder(instance));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ namespace VContainer
{
public static class ContainerBuilderExtensions
{
public static RegistrationBuilder Register<T>(
this IContainerBuilder builder,
Lifetime lifetime)
=> builder.Register(typeof(T), lifetime);

public static RegistrationBuilder Register<TInterface, TImplement>(
this IContainerBuilder builder,
Lifetime lifetime)
Expand Down Expand Up @@ -61,7 +66,7 @@ public static RegistrationBuilder RegisterFactory<TParam1, TParam2, TParam3, TPa
this IContainerBuilder builder,
Func<TParam1, TParam2, TParam3, TParam4, T> factory)
=> builder.RegisterInstance(factory);

public static RegistrationBuilder RegisterFactory<T>(
this IContainerBuilder builder,
Func<IObjectResolver, Func<T>> factoryFactory,
Expand Down