コード例 #1
0
        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();
            }));
        }
コード例 #2
0
ファイル: AutofacBuilder.cs プロジェクト: zuize47/win-acme
        /// <summary>
        /// For revocation and configuration
        /// </summary>
        /// <param name="main"></param>
        /// <param name="runLevel"></param>
        /// <returns></returns>
        public ILifetimeScope Configuration(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.Register(c => runLevel).As <RunLevel>();
                builder.Register(c => resolver).As <IResolver>();
                builder.Register(c => resolver.GetTargetPlugin(main).Result).As <ITargetPluginOptionsFactory>().SingleInstance();
                builder.Register(c => resolver.GetCsrPlugin(main).Result).As <ICsrPluginOptionsFactory>().SingleInstance();
            }));
        }
コード例 #3
0
        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();
            }));
        }