Commit 2aa84847 authored by 阿星Plus's avatar 阿星Plus

dependency

parent abb12214
...@@ -48,7 +48,10 @@ namespace Plus.EntityFramework ...@@ -48,7 +48,10 @@ namespace Plus.EntityFramework
}); });
} }
return _iocResolver.Resolve<TDbContext>(concreteType); return _iocResolver.Resolve<TDbContext>(new
{
options = CreateOptions<TDbContext>(connectionString, existingConnection)
});
} }
catch (DependencyResolverException ex) catch (DependencyResolverException ex)
{ {
......
using Castle.DynamicProxy; using Castle.DynamicProxy;
using Castle.MicroKernel.Registration; using Castle.MicroKernel.Registration;
using Plus.Event;
using System.Reflection; using System.Reflection;
namespace Plus.Dependency namespace Plus.Dependency
...@@ -8,9 +7,9 @@ namespace Plus.Dependency ...@@ -8,9 +7,9 @@ namespace Plus.Dependency
/// <summary> /// <summary>
/// 用于注册基本依赖项实现 /// 用于注册基本依赖项实现
/// </summary> /// </summary>
public class BasicConventionalRegistrar : IDependencyRegistrar public class BasicConventionalRegistrar : IConventionalDependencyRegistrar
{ {
public void RegisterAssembly(IRegistrationContext context) public void RegisterAssembly(IConventionalRegistrationContext context)
{ {
//Transient //Transient
context.IocManager.IocContainer.Register( context.IocManager.IocContainer.Register(
...@@ -43,16 +42,6 @@ namespace Plus.Dependency ...@@ -43,16 +42,6 @@ namespace Plus.Dependency
.WithService.Self() .WithService.Self()
.LifestyleTransient() .LifestyleTransient()
); );
//IConsumer
context.IocManager.IocContainer.Register(
Classes.FromAssembly(context.Assembly)
.IncludeNonPublicTypes()
.BasedOn(typeof(IConsumer<>))
.If(type => !type.GetTypeInfo().IsGenericTypeDefinition)
.WithService.Self()
.LifestyleTransient()
);
} }
} }
} }
\ No newline at end of file
using Castle.DynamicProxy;
using Plus.Configuration;
namespace Plus.Dependency
{
/// <summary>
/// ConventionalRegistrationConfig
/// </summary>
public class ConventionalRegistrationConfig : DictionaryBasedConfig
{
/// <summary>
/// Install all <see cref="IInterceptor"/> implementations automatically or not.
/// Default: true.
/// </summary>
public bool InstallInstallers { get; set; }
/// <summary>
/// Creates a new <see cref="ConventionalRegistrationConfig"/> object.
/// </summary>
public ConventionalRegistrationConfig()
{
InstallInstallers = true;
}
}
}
\ No newline at end of file
...@@ -2,24 +2,31 @@ ...@@ -2,24 +2,31 @@
namespace Plus.Dependency namespace Plus.Dependency
{ {
public class ConventionalRegistrationContext : IRegistrationContext /// <summary>
/// ConventionalRegistrationContext
/// </summary>
internal class ConventionalRegistrationContext : IConventionalRegistrationContext
{ {
public Assembly Assembly /// <summary>
{ /// Gets the registering Assembly.
get; /// </summary>
private set; public Assembly Assembly { get; private set; }
}
public IIocManager IocManager /// <summary>
{ /// Reference to the IOC Container to register types.
get; /// </summary>
private set; public IIocManager IocManager { get; private set; }
}
/// <summary>
/// Registration configuration.
/// </summary>
public ConventionalRegistrationConfig Config { get; private set; }
internal ConventionalRegistrationContext(Assembly assembly, IIocManager iocManager) internal ConventionalRegistrationContext(Assembly assembly, IIocManager iocManager, ConventionalRegistrationConfig config)
{ {
Assembly = assembly; Assembly = assembly;
IocManager = iocManager; IocManager = iocManager;
Config = config;
} }
} }
} }
\ No newline at end of file
namespace Plus.Dependency
{
/// <summary>
/// IConventionalDependencyRegistrar
/// </summary>
public interface IConventionalDependencyRegistrar
{
void RegisterAssembly(IConventionalRegistrationContext context);
}
}
\ No newline at end of file
using System.Reflection;
namespace Plus.Dependency
{
/// <summary>
/// IConventionalRegistrationContext
/// </summary>
public interface IConventionalRegistrationContext
{
/// <summary>
/// Gets the registering Assembly.
/// </summary>
Assembly Assembly { get; }
/// <summary>
/// Reference to the IOC Container to register types.
/// </summary>
IIocManager IocManager { get; }
/// <summary>
/// Registration configuration.
/// </summary>
ConventionalRegistrationConfig Config { get; }
}
}
\ No newline at end of file
...@@ -9,59 +9,67 @@ namespace Plus.Dependency ...@@ -9,59 +9,67 @@ namespace Plus.Dependency
public interface IIocRegistrar public interface IIocRegistrar
{ {
/// <summary> /// <summary>
/// Add Registrar /// Adds a dependency registrar for conventional registration.
/// </summary> /// </summary>
/// <param name="registrar"></param> /// <param name="registrar">dependency registrar</param>
void AddRegistrar(IDependencyRegistrar registrar); void AddConventionalRegistrar(IConventionalDependencyRegistrar registrar);
/// <summary> /// <summary>
/// Register Assembly /// Registers types of given assembly by all conventional registrars. See <see cref="IocManager.AddConventionalRegistrar"/> method.
/// </summary> /// </summary>
/// <param name="assembly"></param> /// <param name="assembly">Assembly to register</param>
void RegisterAssembly(Assembly assembly); void RegisterAssembly(Assembly assembly);
/// <summary> /// <summary>
/// Register /// Registers types of given assembly by all conventional registrars. See <see cref="IocManager.AddConventionalRegistrar"/> method.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <param name="assembly">Assembly to register</param>
/// <param name="lifeStyle"></param> /// <param name="config">Additional configuration</param>
void Register<T>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) where T : class; void RegisterAssembly(Assembly assembly, ConventionalRegistrationConfig config);
/// <summary> /// <summary>
/// Register /// Registers a type as self registration.
/// </summary> /// </summary>
/// <param name="type"></param> /// <typeparam name="T">Type of the class</typeparam>
/// <param name="lifeStyle"></param> /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
void Register<T>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
where T : class;
/// <summary>
/// Registers a type as self registration.
/// </summary>
/// <param name="type">Type of the class</param>
/// <param name="lifeStyle">Lifestyle of the objects of this type</param>
void Register(Type type, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton); void Register(Type type, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton);
/// <summary> /// <summary>
/// Register /// Registers a type with it's implementation.
/// </summary> /// </summary>
/// <typeparam name="TType"></typeparam> /// <typeparam name="TType"></typeparam>
/// <typeparam name="TImpl"></typeparam> /// <typeparam name="TImpl"></typeparam>
/// <param name="lifeStyle"></param> /// <param name="lifeStyle"></param>
void Register<TType, TImpl>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) where TType : class where TImpl : class, TType; void Register<TType, TImpl>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
where TType : class
where TImpl : class, TType;
/// <summary> /// <summary>
/// Register /// Registers a type with it's implementation.
/// </summary> /// </summary>
/// <param name="type"></param> /// <param name="type">Type of the class</param>
/// <param name="impl"></param> /// <param name="impl">The type that implements <paramref name="type"/></param>
/// <param name="lifeStyle"></param> /// <param name="lifeStyle">Lifestyle of the objects of this type</param>
void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton); void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton);
/// <summary> /// <summary>
/// 是否注册了给定的类型 /// Checks whether given type is registered before.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <param name="type">Type to check</param>
/// <returns></returns> bool IsRegistered(Type type);
bool IsRegistered<T>();
/// <summary> /// <summary>
/// 是否注册了给定的类型 /// Checks whether given type is registered before.
/// </summary> /// </summary>
/// <param name="type"></param> /// <typeparam name="TType">Type to check</typeparam>
/// <returns></returns> bool IsRegistered<TType>();
bool IsRegistered(Type type);
} }
} }
\ No newline at end of file
...@@ -8,60 +8,98 @@ namespace Plus.Dependency ...@@ -8,60 +8,98 @@ namespace Plus.Dependency
public interface IIocResolver public interface IIocResolver
{ {
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">Type of the object to get</typeparam>
/// <returns></returns> /// <returns>The object instance</returns>
T Resolve<T>(); T Resolve<T>();
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <param name="type"></param> /// <typeparam name="T">Type of the object to cast</typeparam>
/// <returns></returns> /// <param name="type">Type of the object to resolve</param>
/// <returns>The object instance</returns>
T Resolve<T>(Type type);
/// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary>
/// <typeparam name="T">Type of the object to get</typeparam>
/// <param name="argumentsAsAnonymousType">Constructor arguments</param>
/// <returns>The object instance</returns>
T Resolve<T>(object argumentsAsAnonymousType);
/// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary>
/// <param name="type">Type of the object to get</param>
/// <returns>The object instance</returns>
object Resolve(Type type); object Resolve(Type type);
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <param name="type"></param> /// <param name="type">Type of the object to get</param>
/// <param name="argumentsAsAnonymousType"></param> /// <param name="argumentsAsAnonymousType">Constructor arguments</param>
/// <returns></returns> /// <returns>The object instance</returns>
object Resolve(Type type, object argumentsAsAnonymousType); object Resolve(Type type, object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// Gets all implementations for given type.
/// Returning objects must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">Type of the objects to resolve</typeparam>
/// <param name="argumentsAsAnonymousType"></param> /// <returns>Object instances</returns>
/// <returns></returns> T[] ResolveAll<T>();
T Resolve<T>(object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 从IOC容器中获取对象 /// Gets all implementations for given type.
/// Returning objects must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">Type of the objects to resolve</typeparam>
/// <returns></returns> /// <param name="argumentsAsAnonymousType">Constructor arguments</param>
T[] ResolveAll<T>(); /// <returns>Object instances</returns>
T[] ResolveAll<T>(object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 是否注册了给定的类型 /// Gets all implementations for given type.
/// Returning objects must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <param name="type">Type of the objects to resolve</param>
/// <returns></returns> /// <returns>Object instances</returns>
bool IsRegistered<T>(); object[] ResolveAll(Type type);
/// <summary> /// <summary>
/// 是否注册了给定的类型 /// Gets all implementations for given type.
/// Returning objects must be Released (see <see cref="Release"/>) after usage.
/// </summary> /// </summary>
/// <param name="type"></param> /// <param name="type">Type of the objects to resolve</param>
/// <returns></returns> /// <param name="argumentsAsAnonymousType">Constructor arguments</param>
bool IsRegistered(Type type); /// <returns>Object instances</returns>
object[] ResolveAll(Type type, object argumentsAsAnonymousType);
/// <summary> /// <summary>
/// 释放预解析对象 /// Releases a pre-resolved object. See Resolve methods.
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj">Object to be released</param>
void Release(object obj); void Release(object obj);
/// <summary>
/// Checks whether given type is registered before.
/// </summary>
/// <param name="type">Type to check</param>
bool IsRegistered(Type type);
/// <summary>
/// Checks whether given type is registered before.
/// </summary>
/// <typeparam name="T">Type to check</typeparam>
bool IsRegistered<T>();
} }
} }
\ No newline at end of file
using Castle.MicroKernel.Registration; using Castle.DynamicProxy;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;
using Castle.Windsor; using Castle.Windsor;
using Castle.Windsor.Installer;
using Castle.Windsor.Proxy;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -10,23 +14,44 @@ namespace Plus.Dependency ...@@ -10,23 +14,44 @@ namespace Plus.Dependency
/// <summary> /// <summary>
/// 该类用于直接执行依赖项注入任务 /// 该类用于直接执行依赖项注入任务
/// </summary> /// </summary>
public class IocManager : IIocManager, IIocRegistrar, IIocResolver, IDisposable public class IocManager : IIocManager
{ {
private readonly List<IDependencyRegistrar> _conventionalRegistrars; /// <summary>
/// The Singleton instance.
/// </summary>
public static IocManager Instance { get; private set; }
/// <summary>
/// ProxyGeneratorInstance
/// </summary>
private static readonly ProxyGenerator ProxyGeneratorInstance = new ProxyGenerator();
/// <summary>
/// Reference to the Castle Windsor Container.
/// </summary>
public IWindsorContainer IocContainer { get; private set; } public IWindsorContainer IocContainer { get; private set; }
public static IocManager Instance { get; private set; } /// <summary>
/// List of all registered conventional registrars.
/// </summary>
private readonly List<IConventionalDependencyRegistrar> _conventionalRegistrars;
static IocManager() static IocManager()
{ {
Instance = new IocManager(); Instance = new IocManager();
} }
/// <summary>
/// Creates a new <see cref="IocManager"/> object.
/// Normally, you don't directly instantiate an <see cref="IocManager"/>.
/// This may be useful for test purposes.
/// </summary>
public IocManager() public IocManager()
{ {
IocContainer = new WindsorContainer(); IocContainer = CreateContainer();
_conventionalRegistrars = new List<IDependencyRegistrar>(); _conventionalRegistrars = new List<IConventionalDependencyRegistrar>();
//Register self!
IocContainer.Register( IocContainer.Register(
Component Component
.For<IocManager, IIocManager, IIocRegistrar, IIocResolver>() .For<IocManager, IIocManager, IIocRegistrar, IIocResolver>()
...@@ -34,73 +59,171 @@ namespace Plus.Dependency ...@@ -34,73 +59,171 @@ namespace Plus.Dependency
); );
} }
public void AddRegistrar(IDependencyRegistrar registrar) /// <summary>
/// CreateContainer
/// </summary>
/// <returns></returns>
protected virtual IWindsorContainer CreateContainer()
{
return new WindsorContainer(new DefaultProxyFactory(ProxyGeneratorInstance));
}
/// <summary>
/// Adds a dependency registrar for conventional registration.
/// </summary>
/// <param name="registrar">dependency registrar</param>
public void AddConventionalRegistrar(IConventionalDependencyRegistrar registrar)
{ {
_conventionalRegistrars.Add(registrar); _conventionalRegistrars.Add(registrar);
} }
/// <summary>
/// Registers types of given assembly by all conventional registrars. See <see cref="AddConventionalRegistrar"/> method.
/// </summary>
/// <param name="assembly">Assembly to register</param>
public void RegisterAssembly(Assembly assembly) public void RegisterAssembly(Assembly assembly)
{ {
var context = new RegistrationContext(assembly, this); RegisterAssembly(assembly, new ConventionalRegistrationConfig());
foreach (IDependencyRegistrar conventionalRegistrar in _conventionalRegistrars) }
/// <summary>
/// Registers types of given assembly by all conventional registrars. See <see cref="AddConventionalRegistrar"/> method.
/// </summary>
/// <param name="assembly">Assembly to register</param>
/// <param name="config">Additional configuration</param>
public void RegisterAssembly(Assembly assembly, ConventionalRegistrationConfig config)
{
var context = new ConventionalRegistrationContext(assembly, this, config);
foreach (var registerer in _conventionalRegistrars)
{
registerer.RegisterAssembly(context);
}
if (config.InstallInstallers)
{ {
conventionalRegistrar.RegisterAssembly(context); IocContainer.Install(FromAssembly.Instance(assembly));
} }
} }
/// <summary>
/// Registers a type as self registration.
/// </summary>
/// <typeparam name="TType">Type of the class</typeparam>
/// <param name="lifeStyle">Lifestyle of the objects of this type</param>
public void Register<TType>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) where TType : class public void Register<TType>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) where TType : class
{ {
IocContainer.Register(ApplyLifestyle(Component.For<TType>(), lifeStyle)); IocContainer.Register(ApplyLifestyle(Component.For<TType>(), lifeStyle));
} }
/// <summary>
/// Registers a type as self registration.
/// </summary>
/// <param name="type">Type of the class</param>
/// <param name="lifeStyle">Lifestyle of the objects of this type</param>
public void Register(Type type, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) public void Register(Type type, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
{ {
IocContainer.Register(ApplyLifestyle(Component.For(type), lifeStyle)); IocContainer.Register(ApplyLifestyle(Component.For(type), lifeStyle));
} }
public void Register<TType, TImpl>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) where TType : class where TImpl : class, TType /// <summary>
/// Register
/// </summary>
/// <typeparam name="TType"></typeparam>
/// <typeparam name="TImpl"></typeparam>
/// <param name="lifeStyle"></param>
public void Register<TType, TImpl>(DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
where TType : class
where TImpl : class, TType
{ {
IocContainer.Register(ApplyLifestyle(Component.For<TType, TImpl>().ImplementedBy<TImpl>(), lifeStyle)); IocContainer.Register(ApplyLifestyle(Component.For<TType, TImpl>().ImplementedBy<TImpl>(), lifeStyle));
} }
/// <summary>
/// Registers a type with it's implementation.
/// </summary>
/// <param name="type">Type of the class</param>
/// <param name="impl">The type that implements <paramref name="type"/></param>
/// <param name="lifeStyle">Lifestyle of the objects of this type</param>
public void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) public void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
{ {
IocContainer.Register(ApplyLifestyle(Component.For(type, impl).ImplementedBy(impl), lifeStyle)); IocContainer.Register(ApplyLifestyle(Component.For(type, impl).ImplementedBy(impl), lifeStyle));
} }
/// <summary>
/// Checks whether given type is registered before.
/// </summary>
/// <param name="type">Type to check</param>
public bool IsRegistered(Type type) public bool IsRegistered(Type type)
{ {
return IocContainer.Kernel.HasComponent(type); return IocContainer.Kernel.HasComponent(type);
} }
/// <summary>
/// Checks whether given type is registered before.
/// </summary>
/// <typeparam name="TType">Type to check</typeparam>
public bool IsRegistered<TType>() public bool IsRegistered<TType>()
{ {
return IocContainer.Kernel.HasComponent(typeof(TType)); return IocContainer.Kernel.HasComponent(typeof(TType));
} }
/// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="IIocResolver.Release"/>) after usage.
/// </summary>
/// <typeparam name="T">Type of the object to get</typeparam>
/// <returns>The instance object</returns>
public T Resolve<T>() public T Resolve<T>()
{ {
return IocContainer.Resolve<T>(); return IocContainer.Resolve<T>();
} }
/// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="Release"/>) after usage.
/// </summary>
/// <typeparam name="T">Type of the object to cast</typeparam>
/// <param name="type">Type of the object to resolve</param>
/// <returns>The object instance</returns>
public T Resolve<T>(Type type) public T Resolve<T>(Type type)
{ {
return (T)IocContainer.Resolve(type); return (T)IocContainer.Resolve(type);
} }
public object Resolve(Type type) /// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="IIocResolver.Release"/>) after usage.
/// </summary>
/// <typeparam name="T">Type of the object to get</typeparam>
/// <param name="argumentsAsAnonymousType">Constructor arguments</param>
/// <returns>The instance object</returns>
public T Resolve<T>(object argumentsAsAnonymousType)
{ {
return IocContainer.Resolve(type); return IocContainer.Resolve<T>(Arguments.FromProperties(argumentsAsAnonymousType));
} }
public object Resolve(Type type, object argumentsAsAnonymousType) /// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="IIocResolver.Release"/>) after usage.
/// </summary>
/// <param name="type">Type of the object to get</param>
/// <returns>The instance object</returns>
public object Resolve(Type type)
{ {
return IocContainer.Resolve(type, argumentsAsAnonymousType); return IocContainer.Resolve(type);
} }
public T Resolve<T>(object argumentsAsAnonymousType) /// <summary>
/// Gets an object from IOC container.
/// Returning object must be Released (see <see cref="IIocResolver.Release"/>) after usage.
/// </summary>
/// <param name="type">Type of the object to get</param>
/// <param name="argumentsAsAnonymousType">Constructor arguments</param>
/// <returns>The instance object</returns>
public object Resolve(Type type, object argumentsAsAnonymousType)
{ {
return IocContainer.Resolve<T>(argumentsAsAnonymousType); return IocContainer.Resolve(type, Arguments.FromProperties(argumentsAsAnonymousType));
} }
public T[] ResolveAll<T>() public T[] ResolveAll<T>()
...@@ -110,7 +233,7 @@ namespace Plus.Dependency ...@@ -110,7 +233,7 @@ namespace Plus.Dependency
public T[] ResolveAll<T>(object argumentsAsAnonymousType) public T[] ResolveAll<T>(object argumentsAsAnonymousType)
{ {
return IocContainer.ResolveAll<T>(argumentsAsAnonymousType); return IocContainer.ResolveAll<T>(Arguments.FromProperties(argumentsAsAnonymousType));
} }
public object[] ResolveAll(Type type) public object[] ResolveAll(Type type)
...@@ -120,20 +243,26 @@ namespace Plus.Dependency ...@@ -120,20 +243,26 @@ namespace Plus.Dependency
public object[] ResolveAll(Type type, object argumentsAsAnonymousType) public object[] ResolveAll(Type type, object argumentsAsAnonymousType)
{ {
return IocContainer.ResolveAll(type, argumentsAsAnonymousType).Cast<object>().ToArray(); return IocContainer.ResolveAll(type, Arguments.FromProperties(argumentsAsAnonymousType)).Cast<object>().ToArray();
} }
/// <summary>
/// Releases a pre-resolved object. See Resolve methods.
/// </summary>
/// <param name="obj">Object to be released</param>
public void Release(object obj) public void Release(object obj)
{ {
IocContainer.Release(obj); IocContainer.Release(obj);
} }
/// <inheritdoc/>
public void Dispose() public void Dispose()
{ {
IocContainer.Dispose(); IocContainer.Dispose();
} }
private static ComponentRegistration<T> ApplyLifestyle<T>(ComponentRegistration<T> registration, DependencyLifeStyle lifeStyle) where T : class private static ComponentRegistration<T> ApplyLifestyle<T>(ComponentRegistration<T> registration, DependencyLifeStyle lifeStyle)
where T : class
{ {
switch (lifeStyle) switch (lifeStyle)
{ {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.0" /> <PackageReference Include="Castle.Core" Version="4.4.0" />
<PackageReference Include="Castle.LoggingFacility" Version="4.1.1" /> <PackageReference Include="Castle.LoggingFacility" Version="5.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" />
......
...@@ -18,7 +18,7 @@ namespace Plus ...@@ -18,7 +18,7 @@ namespace Plus
{ {
public override void PreInitialize() public override void PreInitialize()
{ {
IocManager.AddRegistrar(new BasicConventionalRegistrar()); IocManager.AddConventionalRegistrar(new BasicConventionalRegistrar());
ConfigureCaches(); ConfigureCaches();
AddIgnoredTypes(); AddIgnoredTypes();
AddMethodParameterValidators(); AddMethodParameterValidators();
......
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