Skip to content

Commit

Permalink
adding DefaultRules to DryIocContainerExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Apr 24, 2020
1 parent 936e3df commit 70ba338
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
13 changes: 13 additions & 0 deletions src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ public partial class DryIocContainerExtension : IContainerExtension<IContainer>,
{
private IResolverContext _currentScope;

/// <summary>
/// Gets the Default DryIoc Container Rules used by Prism
/// </summary>
public static Rules DefaultRules => Rules.Default.WithAutoConcreteTypeResolution()
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
#if HAS_WINUI || __IOS__
.WithoutFastExpressionCompiler()
#endif
#if HAS_WINUI
.WithTrackingDisposableTransients()
#endif
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace);

/// <summary>
/// The instance of the wrapped container
/// </summary>
Expand Down
7 changes: 1 addition & 6 deletions src/Forms/Prism.DryIoc.Forms/PrismApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ protected override IContainerExtension CreateContainerExtension()
/// Create <see cref="Rules" /> to alter behavior of <see cref="IContainer" />
/// </summary>
/// <returns>An instance of <see cref="Rules" /></returns>
protected virtual Rules CreateContainerRules() => Rules.Default.WithAutoConcreteTypeResolution()
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
#if __IOS__
.WithUseInterpretation()
#endif
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace);
protected virtual Rules CreateContainerRules() => DryIocContainerExtension.DefaultRules;

/// <summary>
/// Configures the Container.
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected virtual void ConfigureContainer()
/// <returns>A new instance of <see cref="IContainer"/>.</returns>
protected virtual IContainer CreateContainer()
{
return new Container(Rules.Default.WithAutoConcreteTypeResolution());
return new Container(DryIocContainerExtension.DefaultRules);
}

protected override IContainerExtension CreateContainerExtension()
Expand Down
9 changes: 1 addition & 8 deletions src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ public abstract class PrismApplication : PrismApplicationBase
/// Create <see cref="Rules" /> to alter behavior of <see cref="IContainer" />
/// </summary>
/// <returns>An instance of <see cref="Rules" /></returns>
protected virtual Rules CreateContainerRules() => Rules.Default.WithAutoConcreteTypeResolution()
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace)
#if HAS_WINUI
.WithoutFastExpressionCompiler()
.WithTrackingDisposableTransients()
#endif
;
protected virtual Rules CreateContainerRules() => DryIocContainerExtension.DefaultRules;

protected override IContainerExtension CreateContainerExtension()
{
Expand Down
4 changes: 1 addition & 3 deletions src/Wpf/Prism.DryIoc.Wpf/PrismBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ public abstract class PrismBootstrapper : PrismBootstrapperBase
/// Create <see cref="Rules" /> to alter behavior of <see cref="IContainer" />
/// </summary>
/// <returns>An instance of <see cref="Rules" /></returns>
protected virtual Rules CreateContainerRules() => Rules.Default.WithAutoConcreteTypeResolution()
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
.WithDefaultIfAlreadyRegistered(IfAlreadyRegistered.Replace);
protected virtual Rules CreateContainerRules() => DryIocContainerExtension.DefaultRules;

protected override IContainerExtension CreateContainerExtension()
{
Expand Down

0 comments on commit 70ba338

Please sign in to comment.