Skip to content

Commit

Permalink
add support for appending multiple registrations and resolving all
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jun 29, 2020
1 parent 117fd60 commit 92be064
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Prism.DryIoc.Extensions/PrismContainerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ public static IContainerExtension Create(IContainer container)
}

[EditorBrowsable(EditorBrowsableState.Never)]
public static Rules CreateContainerRules() => Rules.Default.WithAutoConcreteTypeResolution()
.With(FactoryMethod.ConstructorWithResolvableArguments)
.WithoutThrowOnRegisteringDisposableTransient()
.WithFuncAndLazyWithoutRegistration()
#if __IOS__
.WithUseInterpretation()
#endif
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace);
public static Rules CreateContainerRules() => Rules.Default.WithConcreteTypeDynamicRegistrations()
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
.WithFuncAndLazyWithoutRegistration()
.WithTrackingDisposableTransients()
.WithoutFastExpressionCompiler()
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.AppendNewImplementation)
.WithFactorySelector(Rules.SelectLastRegisteredFactory());

private PrismContainerExtension()
: this(CreateContainerRules())
Expand Down Expand Up @@ -103,7 +102,7 @@ public IContainerRegistry RegisterInstance(Type type, object instance)

public IContainerRegistry RegisterInstance(Type type, object instance, string name)
{
Instance.RegisterInstance(type, instance, serviceKey: name);
Instance.RegisterInstance(type, instance, ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: name);
return this;
}

Expand All @@ -127,7 +126,7 @@ public IContainerRegistry Register(Type from, Type to)

public IContainerRegistry Register(Type from, Type to, string name)
{
Instance.Register(from, to, serviceKey: name);
Instance.Register(from, to, ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: name);
return this;
}

Expand Down Expand Up @@ -155,12 +154,12 @@ public IContainerRegistry RegisterManySingleton(Type implementingType, params Ty

public bool IsRegistered(Type type)
{
return Instance.IsRegistered(type);
return Instance.IsRegistered(type) || Instance.IsRegistered(type, factoryType: FactoryType.Wrapper);
}

public bool IsRegistered(Type type, string name)
{
return Instance.IsRegistered(type, name);
return Instance.IsRegistered(type, name) || Instance.IsRegistered(type, name, factoryType: FactoryType.Wrapper);
}

public IContainerRegistry RegisterDelegate(Type serviceType, Func<object> factoryMethod)
Expand Down

0 comments on commit 92be064

Please sign in to comment.