|
|
|
|
@ -1,9 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
|
using Volo.Abp.Application.Services;
|
|
|
|
|
using Volo.Abp.Modularity;
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.DependencyInjection
|
|
|
|
|
{
|
|
|
|
|
@ -25,45 +21,4 @@ namespace Volo.Abp.DependencyInjection
|
|
|
|
|
Lifetime = lifetime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Dependency(ReplaceServices = true)]
|
|
|
|
|
[ExposeServices(typeof(ITaxCalculator))]
|
|
|
|
|
public class TaxCalculator : ITaxCalculator, ITransientDependency
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITaxCalculator
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BlogModule : AbpModule
|
|
|
|
|
{
|
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
//Add single type
|
|
|
|
|
services.AddType(typeof(TaxCalculator));
|
|
|
|
|
|
|
|
|
|
//Add multiple types in once call
|
|
|
|
|
services.AddTypes(typeof(TaxCalculator), typeof(MyOtherService));
|
|
|
|
|
|
|
|
|
|
//Add single type generic shortcut
|
|
|
|
|
services.AddType<TaxCalculator>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MyService : ITransientDependency
|
|
|
|
|
{
|
|
|
|
|
public ILogger<MyService> Logger { get; set; }
|
|
|
|
|
|
|
|
|
|
public MyService()
|
|
|
|
|
{
|
|
|
|
|
Logger = NullLogger<MyService>.Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DoSomething()
|
|
|
|
|
{
|
|
|
|
|
//...use Logger to write logs...
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|