internal AliasInfo(string name, string definition, CommandManager cmdManager, ScopedItemOptions options) : base(name, CommandTypes.Alias) { Options = options; SetDefinition(definition, cmdManager); }
// internals //internal string UnresolvedCommandName { get; } internal void SetDefinition(string definition, CommandManager cmdManager) { _definition = definition; ReferencedCommand = cmdManager.FindCommand(definition); ResolvedCommand = ReferencedCommand; }
internal AliasInfo(string name, string definition, string description, CommandManager cmdManager, ScopedItemOptions options) : base(name, CommandTypes.Alias) { _cmdManager = cmdManager; Options = options; Description = description; _definition = definition; }
// internals //internal Command Clone(); //internal Command(Command command); internal CommandProcessorBase CreateCommandProcessor(ExecutionContext executionContext, CommandManager commandFactory, bool addToHistory) { CommandProcessorBase cmdProcBase = commandFactory.CreateCommandProcessor(this); cmdProcBase.ExecutionContext = executionContext; cmdProcBase.AddParameters(Parameters); SetMergeResultOptions(cmdProcBase); cmdProcBase.RedirectionVisitor = RedirectionVisitor; return cmdProcBase; }
public void createScopes() { TestHost testHost = new TestHost(new TestHostUserInterface()); Runspace hostRunspace = TestHost.CreateRunspace(testHost); globalState = hostRunspace.ExecutionContext.SessionState; var dummyProviderInfo = new ProviderInfo(globalState, typeof(DummyProvider), "DummyProvider", "", null); globalState.Provider.Add(dummyProviderInfo, hostRunspace.ExecutionContext); dummyProvider = globalState.Provider.GetOne("DummyProvider"); scriptState = new SessionState(globalState); scriptState.IsScriptScope = true; functionState = new SessionState(scriptState); localState = new SessionState(functionState); states = new Dictionary<AvailableStates, SessionState>(); states.Add(AvailableStates.Global, globalState); states.Add(AvailableStates.Script, scriptState); states.Add(AvailableStates.Function, functionState); states.Add(AvailableStates.Local, localState); hostCommandManager = new CommandManager(hostRunspace as LocalRunspace); }
// internals //internal Command Clone(); //internal Command(Command command); internal CommandProcessorBase CreateCommandProcessor(ExecutionContext executionContext, CommandManager commandFactory, bool addToHistory) { CommandProcessorBase cmdProcBase = commandFactory.CreateCommandProcessor(this); cmdProcBase.ExecutionContext = executionContext; if ((Parameters != null) && (Parameters.Count > 0)) { foreach (CommandParameter parameter in Parameters) { if (string.IsNullOrEmpty(parameter.Name)) { cmdProcBase.AddParameter(parameter.Value); } else { cmdProcBase.AddParameter(parameter.Name, parameter.Value); } } } return cmdProcBase; }
internal AliasInfo(string name, string definition, CommandManager cmdManager) : this(name, definition, cmdManager, ScopedItemOptions.None) { }
public override void Open() { CommandManager = new CommandManager(); InitializeSession(); InitializeProviders(); }
public override void Open() { if (PSHost is LocalHost) { // TODO: make sure we use something like IHostSupportsInterativeSession for this // However, for now we need that reference and it's okay as we have a simple // one-to-one relationship between host and runspace ((LocalHost)PSHost).OpenRunspace = this; } CommandManager = new CommandManager(this); InitializeDefaultSnapins(); InitializeSession(); }
public void createScopes() { TestHost testHost = new TestHost(new TestHostUserInterface()); Runspace hostRunspace = TestHost.CreateRunspace(testHost); globalState = hostRunspace.ExecutionContext.SessionState; scriptState = new SessionState(globalState); scriptState.IsScriptScope = true; functionState = new SessionState(scriptState); localState = new SessionState(functionState); states = new Dictionary<AvailableStates, SessionState>(); states.Add(AvailableStates.Global, globalState); states.Add(AvailableStates.Script, scriptState); states.Add(AvailableStates.Function, functionState); states.Add(AvailableStates.Local, localState); hostCommandManager = new CommandManager(hostRunspace as LocalRunspace); }
// internals //internal string UnresolvedCommandName { get; } internal void SetDefinition(string definition, CommandManager cmdManager) { _definition = definition; //only set referenced command if found //aliases only cause errors when they are used, not at instanciation CommandInfo refInfo = null; try { refInfo = cmdManager.FindCommand(definition); } catch (CommandNotFoundException) { } ReferencedCommand = refInfo; ResolvedCommand = ReferencedCommand; }
internal AliasInfo(string name, string definition, CommandManager cmdManager, ScopedItemOptions options) : this(name, definition, "", cmdManager, options) { }