private Starter(Type runnerType, StarterOption option) { Container = new WindsorContainer(); Container.Kernel.ComponentRegistered += (key, handler) => { if (option.DisableAudit) { return; } if (handler.ComponentModel.Implementation.IsDefined(typeof(AuditedAttribute), true)) { handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(AuditingInterceptor))); } }; RegisterAssembly(GetType().Assembly); RegisterAssembly(runnerType.Assembly); Container.Register( Component.For <Starter>().Instance(this).LifestyleSingleton(), Component.For <StarterOption>().Instance(option).LifestyleSingleton() ); IocManager.Container = Container; }
public static Starter Create <T>(StarterOption option = null) where T : IRunner { return(new Starter(typeof(T), option ?? new StarterOption())); }