我正尝试了解有关.Net Core和Castle依赖项注入以及控制反转的更多信息,但是在实现{{1}时,我UseLog4Net
中都找不到LoggingFacility
},也无法在CompositionRoot
中的FromThisAssembly
中实施我的安装程序。我在做什么错了?
CompositionRoot.cs
Classes
DomainInstaller.css
using Castle.Facilities.Logging;
using Castle.Windsor;
namespace PitchulaBeerNBurger.POS.CrossCuttingConcerns.DependencyInjection
{
public class CompositionRoot
{
public virtual void ComposeApplication(IWindsorContainer container)
{
container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
container.Install(
new Installers.CrossCuttingConcerns(),
new Installers.Persistence(),
new Installers.Domain(),
new Installers.Business()
);
}
}
}
已安装NuGet软件包:
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
namespace PitchulaBeerNBurger.POS.CrossCuttingConcerns.Installers
{
public class Domain : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Classes.FromThisAssembly()
.Where(type => type.Name.EndsWith("Factory"))
.LifestyleSingleton());
}
}
}