Skip to content

Commit

Permalink
fixes #61
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Nov 26, 2019
1 parent 4cb9ccf commit 81b20c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
29 changes: 29 additions & 0 deletions src/Prism.Container.Extensions/ContainerExtensionAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.ComponentModel;
using System.Reflection;
using Prism.Ioc;

namespace Prism.Container.Extensions
{
[EditorBrowsable(EditorBrowsableState.Never)]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class ContainerExtensionAttribute : Attribute
{
private Type containerExtensionType { get; }

[EditorBrowsable(EditorBrowsableState.Never)]
public ContainerExtensionAttribute(Type type)
{
containerExtensionType = type;
}

[EditorBrowsable(EditorBrowsableState.Never)]
public IContainerExtension Container => GetContainerExtension();

private IContainerExtension GetContainerExtension()
{
var current = containerExtensionType.GetProperty("Current", BindingFlags.Public | BindingFlags.Static);
return (IContainerExtension)current.GetValue(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Prism.Core" Version="7.2.0.1367" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.1" />
<PackageReference Include="Prism.Core" Version="7.2.0.1422" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Prism.Container.Extensions;
using Prism.Ioc;
using Prism.Microsoft.DependencyInjection;

[assembly: InternalsVisibleTo("Prism.Microsoft.DependencyInjection.Extensions.Tests")]
[assembly: InternalsVisibleTo("Prism.Microsoft.DependencyInjection.Forms.Extended.Tests")]
Expand Down Expand Up @@ -298,7 +300,9 @@ private IServiceProvider GetChildProvider((Type Type, object Instance)[] paramet
services.AddSingleton(param.Type, param.Instance);
}

return services.BuildServiceProvider();
var rootSP = services.BuildServiceProvider();

return new ConcreteAwareServiceProvider(rootSP);
}
}
}

0 comments on commit 81b20c7

Please sign in to comment.