Skip to content

Commit

Permalink
Merge pull request #109 from hadashiA/ku/register-type
Browse files Browse the repository at this point in the history
Add non-generic Register(Type)
  • Loading branch information
hadashiA authored Feb 3, 2021
2 parents 2fb37e5 + aa3117b commit 912dd83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

1 comment on commit 912dd83

@vercel
Copy link

@vercel vercel bot commented on 912dd83 Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.