/// <summary>
        /// Returns true if this is a valid environment position
        /// </summary>
        /// <param name="environments"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static bool IsValid(this IEnvironmentCollection environments, int index)
        {
            Assert.ArgumentNotNull(environments, nameof(environments));
            var allEnvs = environments.GetNames();

            return(index >= 0 && index < allEnvs.Count);
        }
 public CommandDispatcher(ICommandParser parser, IHandlers handlers, IEnvironmentCollection environments, EngineState state, IOutput output)
 {
     Parser       = parser;
     Handlers     = handlers;
     Environments = environments;
     State        = state;
     Output       = output;
 }
Example #3
0
 public EnvironmentHandler(IOutput output, IArguments args, EngineState state, IEnvironmentCollection environments, CommandDispatcher dispatcher)
 {
     _output       = output;
     _args         = args;
     _state        = state;
     _environments = environments;
     _dispatcher   = dispatcher;
 }
        /// <summary>
        /// Sets the current environment by position
        /// </summary>
        /// <param name="environments"></param>
        /// <param name="index"></param>
        public static void SetCurrent(this IEnvironmentCollection environments, int index)
        {
            Assert.ArgumentNotNull(environments, nameof(environments));
            var allEnvs = environments.GetNames();

            if (index < 0 || index >= allEnvs.Count)
            {
                return;
            }
            environments.SetCurrent(allEnvs[index]);
        }
Example #5
0
        public IEnvironmentSetup UseInstances(IReadOnlyDictionary <string, object> environments)
        {
            if (environments == null)
            {
                _environments = null;
                return(this);
            }

            EnsureEnvironmentsNotSet();
            _environments = new FactoryEnvironmentCollection(new DictionaryEnvironmentFactory(environments));
            return(this);
        }
Example #6
0
        public IEnvironmentSetup UseFactory(IEnvironmentFactory factory)
        {
            if (factory == null)
            {
                _environments = null;
                return(this);
            }

            EnsureEnvironmentsNotSet();
            _environments = new FactoryEnvironmentCollection(factory);
            return(this);
        }
Example #7
0
        public Engine(IHandlers handlers, IEnvironmentCollection environments, ICommandParser parser, IOutput output, EngineEventCatalog eventCatalog, EngineSettings settings)
        {
            Assert.ArgumentNotNull(handlers, nameof(handlers));
            Assert.ArgumentNotNull(environments, nameof(environments));
            Assert.ArgumentNotNull(parser, nameof(parser));
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(eventCatalog, nameof(eventCatalog));

            Environments  = environments;
            _handlers     = handlers;
            _eventCatalog = eventCatalog;
            _settings     = settings;
            _parser       = parser;
            Output        = output;
        }
 public PromptCommandSource(IOutput output, IEnvironmentCollection environments, EngineState state)
 {
     _output       = output;
     _environments = environments;
     _state        = state;
 }
 public DeploymentInfo(IEnvironmentCollection environments)
 {
     this.environments = environments;
 }
Example #10
0
 public IEnvironmentSetup UseInstance(object environment)
 {
     EnsureEnvironmentsNotSet();
     _environments = new InstanceEnvironmentCollection(environment);
     return(this);
 }