using System;
using Abp.Dependency;
namespace Abp.Configuration.Startup
{
///
/// Extension methods for .
///
public static class AbpStartupConfigurationExtensions
{
///
/// Used to replace a service type.
///
/// The configuration.
/// Type.
/// Implementation.
/// Life style.
public static void ReplaceService(this IAbpStartupConfiguration configuration, Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
{
configuration.ReplaceService(type, () =>
{
configuration.IocManager.Register(type, impl, lifeStyle);
});
}
///
/// Used to replace a service type.
///
/// Type of the service.
/// Type of the implementation.
/// The configuration.
/// Life style.
public static void ReplaceService(this IAbpStartupConfiguration configuration, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
where TType : class
where TImpl : class, TType
{
configuration.ReplaceService(typeof(TType), () =>
{
configuration.IocManager.Register(lifeStyle);
});
}
///
/// Used to replace a service type.
///
/// Type of the service.
/// The configuration.
/// Replace action.
public static void ReplaceService(this IAbpStartupConfiguration configuration, Action replaceAction)
where TType : class
{
configuration.ReplaceService(typeof(TType), replaceAction);
}
}
}