Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IMyClass
- {
- void Log();
- }
- public class MyClass : IMyClass
- {
- private ILogger logger;
- public MyClass(ILogger logger)
- {
- this.logger = logger;
- }
- public void Log()
- {
- logger.Info("I can log");
- }
- }
- public class LoggerInstaller : IWindsorInstaller
- {
- public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
- {
- container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var container = new WindsorContainer().Install(FromAssembly.This());
- container.Register(Component.For<IMyClass>()
- .ImplementedBy<MyClass>()
- .LifestyleTransient());
- var myClass = container.Resolve<IMyClass>();
- myClass.Log();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement