예제 #1
0
파일: AliasInfo.cs 프로젝트: b333z/Pash
        internal AliasInfo(string name, string definition, CommandManager cmdManager, ScopedItemOptions options)
            : base(name, CommandTypes.Alias)
        {
            Options = options;

            SetDefinition(definition, cmdManager);
        }
예제 #2
0
파일: AliasInfo.cs 프로젝트: b333z/Pash
        // internals
        //internal string UnresolvedCommandName { get; }
        internal void SetDefinition(string definition, CommandManager cmdManager)
        {
            _definition = definition;

            ReferencedCommand = cmdManager.FindCommand(definition);
            ResolvedCommand = ReferencedCommand;
        }
예제 #3
0
파일: AliasInfo.cs 프로젝트: mauve/Pash
 internal AliasInfo(string name, string definition, string description, CommandManager cmdManager, ScopedItemOptions options)
     : base(name, CommandTypes.Alias)
 {
     _cmdManager = cmdManager;
     Options = options;
     Description = description;
     _definition = definition;
 }
예제 #4
0
파일: Command.cs 프로젝트: mauve/Pash
 // 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;
 }
예제 #5
0
        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);
        }
예제 #6
0
        // 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;
        }
예제 #7
0
파일: AliasInfo.cs 프로젝트: b333z/Pash
 internal AliasInfo(string name, string definition, CommandManager cmdManager)
     : this(name, definition, cmdManager, ScopedItemOptions.None)
 {
 }
예제 #8
0
 public override void Open()
 {
     CommandManager = new CommandManager();
     InitializeSession();
     InitializeProviders();
 }
예제 #9
0
 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();
 }
예제 #10
0
        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);
        }
예제 #11
0
파일: AliasInfo.cs 프로젝트: Ventero/Pash
        // 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;
        }
예제 #12
0
파일: AliasInfo.cs 프로젝트: mauve/Pash
 internal AliasInfo(string name, string definition, CommandManager cmdManager, ScopedItemOptions options)
     :  this(name, definition, "", cmdManager, options)
 {
 }