Exemplo n.º 1
0
        public StaticContext(IOptions <StaticOptions> optionsAccessor, IHostingEnvironment env)
        {
            if (optionsAccessor == null)
            {
                throw new ArgumentNullException(nameof(optionsAccessor));
            }

            if (env == null)
            {
                throw new ArgumentNullException(nameof(env));
            }

            var options = optionsAccessor.Value;
            var manifestRootRelativePath = options.ManifestDirectoryPath
                                           .Value
                                           .TrimStart('/')
                                           .Replace('/', Path.DirectorySeparatorChar);
            var manifestRootPath     = Path.Combine(env.WebRootPath, manifestRootRelativePath);
            var manifestPhysicalPath = Path.Combine(manifestRootPath, options.ManifestFileName);
            var fileProvider         = new PhysicalFileProvider(manifestRootPath);

            this.manifestPhysicalPath = manifestPhysicalPath;
            this.fileProvider         = fileProvider;
            this.options = options;
        }
Exemplo n.º 2
0
        private static async Task <int> RemoveNewAppConfigAsync(RemoveNewAppConfigOptions options)
        {
            VerboseLevel Map(int value)
            {
                switch (value)
                {
                case 3:
                    return(VerboseLevel.High);

                case 2:
                    return(VerboseLevel.Medium);

                case 1:
                    return(VerboseLevel.Low);

                case 0:
                    return(VerboseLevel.Disabled);
                }

                return(VerboseLevel.Disabled);
            }

            var staticOptions = new StaticOptions(
                Map(options.Verbose),
                options.DryRun,
                options.HoldOnExit,
                options.SearchProvider,
                options.SourceControlProvider);

            Bootstrapper.Container.Register(typeof(IHoldOnExitOption), () => staticOptions, Lifestyle.Scoped);
            Bootstrapper.Container.Register(typeof(IDryRunOption), () => staticOptions, Lifestyle.Scoped);
            Bootstrapper.Container.Register(typeof(ISearchProviderNameOption), () => staticOptions, Lifestyle.Scoped);
            Bootstrapper.Container.Register(typeof(IVerboseOption), () => staticOptions, Lifestyle.Scoped);
            Bootstrapper.Container.Register(typeof(ISourceControlNameOption), () => staticOptions, Lifestyle.Scoped);

            using (Bootstrapper.StartSession())
            {
                var commandHandler = Bootstrapper.Container.GetInstance <ICommandHandler <CleanAppConfigCommand> >();
                await commandHandler.ExecuteAsync(new CleanAppConfigCommand(options.RootDirectory)).ConfigureAwait(true);
            }

            return(0);
        }
 public ValuesController(IOptionsSnapshot <StaticOptions> staticConfig, IOptionsSnapshot <ConfigMapOptions> mapConfig)
 {
     _staticConfig = staticConfig.Value;
     _mapConfig    = mapConfig.Value;
 }