Commit 9acef28e authored by 阿星Plus's avatar 阿星Plus

😥😥😥

parent e4a9da1e
using Microsoft.EntityFrameworkCore; using Castle.MicroKernel.Resolvers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Plus.Dependency; using Plus.Dependency;
using Plus.EntityFramework.Configuration; using Plus.EntityFramework.Configuration;
...@@ -41,12 +42,15 @@ namespace Plus.EntityFramework ...@@ -41,12 +42,15 @@ namespace Plus.EntityFramework
{ {
if (isAbstractDbContext) if (isAbstractDbContext)
{ {
return (TDbContext)_iocResolver.Resolve(concreteType); return (TDbContext)_iocResolver.Resolve(concreteType, new
{
options = CreateOptionsForType(concreteType, connectionString, existingConnection)
});
} }
return _iocResolver.Resolve<TDbContext>(concreteType); return _iocResolver.Resolve<TDbContext>(concreteType);
} }
catch (Castle.MicroKernel.Resolvers.DependencyResolverException ex) catch (DependencyResolverException ex)
{ {
var hasOptions = isAbstractDbContext ? HasOptions(concreteType) : HasOptions(dbContextType); var hasOptions = isAbstractDbContext ? HasOptions(concreteType) : HasOptions(dbContextType);
if (!hasOptions) if (!hasOptions)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl> <PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;plus.entityframework;.netcoreplus;</PackageTags> <PackageTags>plus;plus.entityframework;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus.EntityFramework</PackageReleaseNotes> <PackageReleaseNotes>Plus.EntityFramework</PackageReleaseNotes>
<Version>1.0.0.2</Version> <Version>1.0.0.3</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......
...@@ -21,20 +21,28 @@ namespace Plus.Dependency ...@@ -21,20 +21,28 @@ namespace Plus.Dependency
/// <returns></returns> /// <returns></returns>
object Resolve(Type type); object Resolve(Type type);
/// <summary>
/// 从IOC容器中获取对象
/// </summary>
/// <param name="type"></param>
/// <param name="argumentsAsAnonymousType"></param>
/// <returns></returns>
object Resolve(Type type, object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// 从IOC容器中获取对象
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="argumentsAsAnonymousType"></param>
/// <returns></returns> /// <returns></returns>
T[] ResolveAll<T>(); T Resolve<T>(object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// 从IOC容器中获取对象
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="type"></param>
/// <returns></returns> /// <returns></returns>
T Resolve<T>(Type type); T[] ResolveAll<T>();
/// <summary> /// <summary>
/// 是否注册了给定的类型 /// 是否注册了给定的类型
......
...@@ -25,8 +25,7 @@ namespace Plus.Dependency.Installers ...@@ -25,8 +25,7 @@ namespace Plus.Dependency.Installers
Component.For<IAssemblyFinder, AssemblyFinder>().ImplementedBy<AssemblyFinder>().LifestyleSingleton(), Component.For<IAssemblyFinder, AssemblyFinder>().ImplementedBy<AssemblyFinder>().LifestyleSingleton(),
Component.For<ITypeFinder, TypeFinder>().ImplementedBy<TypeFinder>().LifestyleSingleton(), Component.For<ITypeFinder, TypeFinder>().ImplementedBy<TypeFinder>().LifestyleSingleton(),
Component.For<ICachingConfiguration, CachingConfiguration>().ImplementedBy<CachingConfiguration>().LifestyleSingleton(), Component.For<ICachingConfiguration, CachingConfiguration>().ImplementedBy<CachingConfiguration>().LifestyleSingleton(),
Component.For<IValidationConfiguration, ValidationConfiguration>().ImplementedBy<ValidationConfiguration>().LifestyleSingleton(), Component.For<IValidationConfiguration, ValidationConfiguration>().ImplementedBy<ValidationConfiguration>().LifestyleSingleton()
Component.For<IEventBusConfiguration, EventBusConfiguration>().ImplementedBy<EventBusConfiguration>().LifestyleSingleton()
); );
} }
} }
......
...@@ -93,16 +93,36 @@ namespace Plus.Dependency ...@@ -93,16 +93,36 @@ namespace Plus.Dependency
return IocContainer.Resolve(type); return IocContainer.Resolve(type);
} }
public object Resolve(Type type, object argumentsAsAnonymousType)
{
return IocContainer.Resolve(type, argumentsAsAnonymousType);
}
public T Resolve<T>(object argumentsAsAnonymousType)
{
return IocContainer.Resolve<T>(argumentsAsAnonymousType);
}
public T[] ResolveAll<T>() public T[] ResolveAll<T>()
{ {
return IocContainer.ResolveAll<T>(); return IocContainer.ResolveAll<T>();
} }
public T[] ResolveAll<T>(object argumentsAsAnonymousType)
{
return IocContainer.ResolveAll<T>(argumentsAsAnonymousType);
}
public object[] ResolveAll(Type type) public object[] ResolveAll(Type type)
{ {
return IocContainer.ResolveAll(type).Cast<object>().ToArray(); return IocContainer.ResolveAll(type).Cast<object>().ToArray();
} }
public object[] ResolveAll(Type type, object argumentsAsAnonymousType)
{
return IocContainer.ResolveAll(type, argumentsAsAnonymousType).Cast<object>().ToArray();
}
public void Release(object obj) public void Release(object obj)
{ {
IocContainer.Release(obj); IocContainer.Release(obj);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
using Castle.MicroKernel.Registration; using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration; using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor; using Castle.Windsor;
using Plus.Configuration.Startup;
using Plus.Dependency; using Plus.Dependency;
using Plus.Event.Bus.Factories; using Plus.Event.Bus.Factories;
using Plus.Event.Bus.Handlers; using Plus.Event.Bus.Handlers;
...@@ -16,29 +15,18 @@ namespace Plus.Event.Bus ...@@ -16,29 +15,18 @@ namespace Plus.Event.Bus
internal class EventBusInstaller : IWindsorInstaller internal class EventBusInstaller : IWindsorInstaller
{ {
private readonly IIocResolver _iocResolver; private readonly IIocResolver _iocResolver;
private readonly IEventBusConfiguration _eventBusConfiguration;
private IEventBus _eventBus; private IEventBus _eventBus;
public EventBusInstaller(IIocResolver iocResolver) public EventBusInstaller(IIocResolver iocResolver)
{ {
_iocResolver = iocResolver; _iocResolver = iocResolver;
_eventBusConfiguration = iocResolver.Resolve<IEventBusConfiguration>();
} }
public void Install(IWindsorContainer container, IConfigurationStore store) public void Install(IWindsorContainer container, IConfigurationStore store)
{
if (_eventBusConfiguration.UseDefaultEventBus)
{ {
container.Register( container.Register(
Component.For<IEventBus>().Instance(EventBus.Default).LifestyleSingleton() Component.For<IEventBus>().Instance(EventBus.Default).LifestyleSingleton()
); );
}
else
{
container.Register(
Component.For<IEventBus>().ImplementedBy<EventBus>().LifestyleSingleton()
);
}
_eventBus = container.Resolve<IEventBus>(); _eventBus = container.Resolve<IEventBus>();
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl> <PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags> <PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes> <PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.3.2</Version> <Version>1.0.3.3</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.0" /> <PackageReference Include="Castle.Core" Version="4.4.0" />
<PackageReference Include="Castle.Windsor" Version="5.0.0" /> <PackageReference Include="Castle.Windsor" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment