Skip to content

Commit

Permalink
chore: update DryIoc
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Feb 8, 2023
1 parent 2ac97e2 commit 4a021d8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<ItemGroup>
<PackageVersion Include="DryIoc.dll" Version="4.8.0" />
<PackageVersion Include="DryIoc.dll" Version="5.3.1" />
<PackageVersion Include="Unity.Container" Version="5.11.11" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="Xamarin.Forms" Version="5.0.0.2401" />
Expand Down
42 changes: 31 additions & 11 deletions src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using System;
using System.Linq;
using DryIoc;
using Prism.Ioc;
using Prism.Ioc.Internals;
using IContainer = DryIoc.IContainer;

namespace Prism.DryIoc
{
/// <summary>
/// The <see cref="IContainerExtension" /> Implementation to use with DryIoc
/// </summary>
#if ContainerExtensions
internal partial
internal
#else
public
#endif
class DryIocContainerExtension : IContainerExtension<IContainer>, IContainerInfo
partial class DryIocContainerExtension : IContainerExtension<IContainer>, IContainerInfo
{
private DryIocScopedProvider _currentScope;

Expand All @@ -25,7 +24,7 @@ class DryIocContainerExtension : IContainerExtension<IContainer>, IContainerInfo
.With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
.WithFuncAndLazyWithoutRegistration()
.WithTrackingDisposableTransients()
.WithoutFastExpressionCompiler()
// .WithoutFastExpressionCompiler()
.WithFactorySelector(Rules.SelectLastRegisteredFactory());

/// <summary>
Expand All @@ -38,7 +37,12 @@ class DryIocContainerExtension : IContainerExtension<IContainer>, IContainerInfo
/// Constructs a default instance of the <see cref="DryIocContainerExtension" />
/// </summary>
public DryIocContainerExtension()
: this(new Container(DefaultRules))
: this(DefaultRules)
{
}

public DryIocContainerExtension(Rules rules)
: this(new Container(rules))
{
}

Expand Down Expand Up @@ -291,7 +295,11 @@ public object Resolve(Type type, params (Type Type, object Instance)[] parameter
try
{
var container = _currentScope?.Resolver ?? Instance;
return container.Resolve(type, args: parameters.Select(p => p.Instance).ToArray());
var args = parameters.Where(x => x.Instance is not IContainerProvider)
.Select(x => x.Instance)
.ToList();
args.Add(this);
return container.Resolve(type, args: args.ToArray());
}
catch (Exception ex)
{
Expand All @@ -311,7 +319,11 @@ public object Resolve(Type type, string name, params (Type Type, object Instance
try
{
var container = _currentScope?.Resolver ?? Instance;
return container.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray());
var args = parameters.Where(x => x.Instance is not IContainerProvider)
.Select(x => x.Instance)
.ToList();
args.Add(this);
return container.Resolve(type, name, args: args.ToArray());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -387,7 +399,7 @@ public DryIocScopedProvider(IResolverContext resolver)
public IResolverContext Resolver { get; private set; }
public IScopedProvider CurrentScope => this;

public IScopedProvider CreateScope() => this;
public IScopedProvider CreateScope() => new DryIocScopedProvider(Resolver.OpenScope());

public void Dispose()
{
Expand All @@ -405,7 +417,11 @@ public object Resolve(Type type, params (Type Type, object Instance)[] parameter
{
try
{
return Resolver.Resolve(type, args: parameters.Select(p => p.Instance).ToArray());
var args = parameters.Where(x => x.Instance is not IContainerProvider)
.Select(x => x.Instance)
.ToList();
args.Add(this);
return Resolver.Resolve(type, args: args.ToArray());
}
catch (Exception ex)
{
Expand All @@ -417,7 +433,11 @@ public object Resolve(Type type, string name, params (Type Type, object Instance
{
try
{
return Resolver.Resolve(type, name, args: parameters.Select(p => p.Instance).ToArray());
var args = parameters.Where(x => x.Instance is not IContainerProvider)
.Select(x => x.Instance)
.ToList();
args.Add(this);
return Resolver.Resolve(type, name, args: args.ToArray());
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Containers/Prism.DryIoc.Shared/PrismIocExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using DryIoc;
using Prism.Ioc;
using Prism.Ioc;
using IContainer = DryIoc.IContainer;

namespace Prism.DryIoc
{
Expand Down
2 changes: 1 addition & 1 deletion src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="5.3.1" />
<PackageReference Include="DryIoc.dll" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 4a021d8

Please sign in to comment.