internal static ILifetimeScope Renewal(IContainer main, ScheduledRenewal renewal, bool interactive) { IResolver resolver = null; if (interactive) { resolver = main.Resolve <InteractiveResolver>(new TypedParameter(typeof(ScheduledRenewal), renewal)); } else { resolver = main.Resolve <UnattendedResolver>(new TypedParameter(typeof(ScheduledRenewal), renewal)); } return(main.BeginLifetimeScope(builder => { builder.RegisterType <LetsEncryptClient>().SingleInstance(); builder.RegisterType <CertificateService>().SingleInstance(); builder.RegisterInstance(resolver); builder.RegisterInstance(renewal); builder.Register(c => resolver.GetTargetPlugin(main)).As <ITargetPluginFactory>().SingleInstance(); builder.Register(c => resolver.GetInstallationPlugins(main)).As <List <IInstallationPluginFactory> >().SingleInstance(); builder.Register(c => resolver.GetValidationPlugin(main)).As <IValidationPluginFactory>().SingleInstance(); builder.Register(c => resolver.GetStorePlugin(main)).As <IStorePluginFactory>().SingleInstance(); builder.Register(c => c.Resolve(c.Resolve <ITargetPluginFactory>().Instance)).As <ITargetPlugin>().SingleInstance(); builder.Register(c => c.Resolve(c.Resolve <IStorePluginFactory>().Instance)).As <IStorePlugin>().SingleInstance(); })); }
/// <summary> /// For configuration and renewal /// </summary> /// <param name="main"></param> /// <param name="renewal"></param> /// <param name="runLevel"></param> /// <returns></returns> public ILifetimeScope Target(ILifetimeScope main, Renewal renewal, RunLevel runLevel) { IResolver resolver = null; if (runLevel.HasFlag(RunLevel.Interactive)) { resolver = main.Resolve <InteractiveResolver>(new TypedParameter(typeof(RunLevel), runLevel)); } else { resolver = main.Resolve <UnattendedResolver>(); } return(main.BeginLifetimeScope(builder => { builder.RegisterInstance(renewal.TargetPluginOptions).As(renewal.TargetPluginOptions.GetType()); builder.RegisterType(renewal.TargetPluginOptions.Instance).As <ITargetPlugin>().SingleInstance(); builder.Register(c => c.Resolve <ITargetPlugin>().Generate().Result).As <Target>().SingleInstance(); builder.Register(c => resolver.GetValidationPlugin(main, c.Resolve <Target>()).Result).As <IValidationPluginOptionsFactory>().SingleInstance(); })); }
internal static ILifetimeScope Renewal(IContainer main, ScheduledRenewal renewal, RunLevel runLevel, int type = 0) { IResolver resolver = null; if (runLevel > RunLevel.Unattended) { resolver = main.Resolve <InteractiveResolver>( new TypedParameter(typeof(ScheduledRenewal), renewal), new TypedParameter(typeof(RunLevel), runLevel) , new TypedParameter(typeof(int), type)); } else { resolver = main.Resolve <UnattendedResolver>(new TypedParameter(typeof(ScheduledRenewal), renewal)); } return(main.BeginLifetimeScope(builder => { builder.RegisterType <AcmeClientWrapper>().SingleInstance(); builder.RegisterType <CertificateService>().SingleInstance(); builder.RegisterInstance(resolver); if (renewal != null) { builder.RegisterInstance(renewal); } builder.Register(c => runLevel).As <RunLevel>(); builder.RegisterType <TaskSchedulerService>(). WithParameter(new TypedParameter(typeof(RunLevel), runLevel)). SingleInstance(); builder.Register(c => resolver.GetTargetPlugin(main)).As <ITargetPluginFactory>().SingleInstance(); builder.Register(c => resolver.GetInstallationPlugins(main)).As <List <IInstallationPluginFactory> >().SingleInstance(); builder.Register(c => resolver.GetValidationPlugin(main)).As <IValidationPluginFactory>().SingleInstance(); builder.Register(c => resolver.GetStorePlugin(main)).As <IStorePluginFactory>().SingleInstance(); builder.Register(c => c.Resolve(c.Resolve <ITargetPluginFactory>().Instance)).As <ITargetPlugin>().SingleInstance(); builder.Register(c => c.Resolve(c.Resolve <IStorePluginFactory>().Instance)).As <IStorePlugin>().SingleInstance(); })); }