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 Plus.Dependency;
using Plus.EntityFramework.Configuration;
......@@ -41,12 +42,15 @@ namespace Plus.EntityFramework
{
if (isAbstractDbContext)
{
return (TDbContext)_iocResolver.Resolve(concreteType);
return (TDbContext)_iocResolver.Resolve(concreteType, new
{
options = CreateOptionsForType(concreteType, connectionString, existingConnection)
});
}
return _iocResolver.Resolve<TDbContext>(concreteType);
}
catch (Castle.MicroKernel.Resolvers.DependencyResolverException ex)
catch (DependencyResolverException ex)
{
var hasOptions = isAbstractDbContext ? HasOptions(concreteType) : HasOptions(dbContextType);
if (!hasOptions)
......
......@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;plus.entityframework;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus.EntityFramework</PackageReleaseNotes>
<Version>1.0.0.2</Version>
<Version>1.0.0.3</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......
......@@ -21,20 +21,28 @@ namespace Plus.Dependency
/// <returns></returns>
object Resolve(Type type);
/// <summary>
/// 从IOC容器中获取对象
/// </summary>
/// <param name="type"></param>
/// <param name="argumentsAsAnonymousType"></param>
/// <returns></returns>
object Resolve(Type type, object argumentsAsAnonymousType);
/// <summary>
/// 从IOC容器中获取对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="argumentsAsAnonymousType"></param>
/// <returns></returns>
T[] ResolveAll<T>();
T Resolve<T>(object argumentsAsAnonymousType);
/// <summary>
/// 从IOC容器中获取对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="type"></param>
/// <returns></returns>
T Resolve<T>(Type type);
T[] ResolveAll<T>();
/// <summary>
/// 是否注册了给定的类型
......
......@@ -25,8 +25,7 @@ namespace Plus.Dependency.Installers
Component.For<IAssemblyFinder, AssemblyFinder>().ImplementedBy<AssemblyFinder>().LifestyleSingleton(),
Component.For<ITypeFinder, TypeFinder>().ImplementedBy<TypeFinder>().LifestyleSingleton(),
Component.For<ICachingConfiguration, CachingConfiguration>().ImplementedBy<CachingConfiguration>().LifestyleSingleton(),
Component.For<IValidationConfiguration, ValidationConfiguration>().ImplementedBy<ValidationConfiguration>().LifestyleSingleton(),
Component.For<IEventBusConfiguration, EventBusConfiguration>().ImplementedBy<EventBusConfiguration>().LifestyleSingleton()
Component.For<IValidationConfiguration, ValidationConfiguration>().ImplementedBy<ValidationConfiguration>().LifestyleSingleton()
);
}
}
......
......@@ -93,16 +93,36 @@ namespace Plus.Dependency
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>()
{
return IocContainer.ResolveAll<T>();
}
public T[] ResolveAll<T>(object argumentsAsAnonymousType)
{
return IocContainer.ResolveAll<T>(argumentsAsAnonymousType);
}
public object[] ResolveAll(Type type)
{
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)
{
IocContainer.Release(obj);
......
......@@ -2,7 +2,6 @@
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Plus.Configuration.Startup;
using Plus.Dependency;
using Plus.Event.Bus.Factories;
using Plus.Event.Bus.Handlers;
......@@ -16,29 +15,18 @@ namespace Plus.Event.Bus
internal class EventBusInstaller : IWindsorInstaller
{
private readonly IIocResolver _iocResolver;
private readonly IEventBusConfiguration _eventBusConfiguration;
private IEventBus _eventBus;
public EventBusInstaller(IIocResolver iocResolver)
{
_iocResolver = iocResolver;
_eventBusConfiguration = iocResolver.Resolve<IEventBusConfiguration>();
}
public void Install(IWindsorContainer container, IConfigurationStore store)
{
if (_eventBusConfiguration.UseDefaultEventBus)
{
container.Register(
Component.For<IEventBus>().Instance(EventBus.Default).LifestyleSingleton()
);
}
else
{
container.Register(
Component.For<IEventBus>().ImplementedBy<EventBus>().LifestyleSingleton()
);
}
container.Register(
Component.For<IEventBus>().Instance(EventBus.Default).LifestyleSingleton()
);
_eventBus = container.Resolve<IEventBus>();
......
......@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.3.2</Version>
<Version>1.0.3.3</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......@@ -26,7 +26,7 @@
<ItemGroup>
<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.Configuration" 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