forked from aspnetboilerplate/aspnetboilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added overloads for IAbpStartupConfiguration.ReplaceService aspnetboi…
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Abp/Configuration/Startup/AbpStartupConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using Abp.Dependency; | ||
|
||
namespace Abp.Configuration.Startup | ||
{ | ||
/// <summary> | ||
/// Extension methods for <see cref="IAbpStartupConfiguration"/>. | ||
/// </summary> | ||
public static class AbpStartupConfigurationExtensions | ||
{ | ||
/// <summary> | ||
/// Used to replace a service type. | ||
/// </summary> | ||
/// <param name="configuration">The configuration.</param> | ||
/// <param name="type">Type.</param> | ||
/// <param name="impl">Implementation.</param> | ||
/// <param name="lifeStyle">Life style.</param> | ||
public static void ReplaceService(this IAbpStartupConfiguration configuration, Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) | ||
{ | ||
configuration.ReplaceService(type, () => | ||
{ | ||
configuration.IocManager.Register(type, impl, lifeStyle); | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// Used to replace a service type. | ||
/// </summary> | ||
/// <typeparam name="TType">Type of the service.</typeparam> | ||
/// <typeparam name="TImpl">Type of the implementation.</typeparam> | ||
/// <param name="configuration">The configuration.</param> | ||
/// <param name="lifeStyle">Life style.</param> | ||
public static void ReplaceService<TType, TImpl>(this IAbpStartupConfiguration configuration, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton) | ||
where TType : class | ||
where TImpl : class, TType | ||
{ | ||
configuration.ReplaceService(typeof(TType), () => | ||
{ | ||
configuration.IocManager.Register<TType, TImpl>(lifeStyle); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters