Exemplo n.º 1
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
        public SessionManager(FilePath configurationPath,
                              IBootstrapper bootstrapper,
                              IConfigurationManager configurationManager,
                              IModuleManager moduleManager,
                              IFileSystem fileSystem)
        {
            this.moduleManager        = moduleManager;
            this.configurationManager = configurationManager;
            this.fileSystem           = fileSystem;

            GlobalHook.Initialize();

            bootstrapper.ComposeImports(this);
            bootstrapper.ComposeImports(configurationManager);
            bootstrapper.ComposeImports(moduleManager);

            configurationManager.LoadConfiguration(configurationPath);

            encoders = Encoders.Where(x => Configuration.Encoders.Contains(x.GetType()));
            decoders = Decoders.Where(x => Configuration.Decoders?.Contains(x.GetType()) ?? false);
        }
Exemplo n.º 2
0
        public int Execute(ValidateOptions options)
        {
            Debug.Assert(consoleFormatter != null, nameof(consoleFormatter) + " != null");
            Debug.Assert(bootstrapper != null, nameof(bootstrapper) + " != null");

            if (options == null)
            {
                return(-1);
            }

            try
            {
                consoleFormatter.IsVerbose = options.IsVerbose;

                // Load Configuration File
                consoleFormatter.PrintDebug(loadedFileMessage);
                var filePath = new FilePath(Path.GetFullPath(options.ConfigPath));

                // Start Configuration Manager and Bootstrapper
                consoleFormatter.PrintDebug(assemblyMessage);
                bootstrapper.ComposeImports(configurationManager);

                // Resolve Configuration File
                consoleFormatter.PrintDebug(resolveConfigMessage);
                configurationManager.LoadConfiguration(filePath);

                Console.WriteLine(successMessage);
                return(0);
            }
            catch (InvalidConfigurationException exception)
            {
                consoleFormatter.PrintError(exception);
                Console.WriteLine(failureMessage);
                return(1);
            }
            catch (Exception exception)
            {
                consoleFormatter.PrintError(exception);
                return(-1);
            }
        }