コード例 #1
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingParameterSetSelectionSingleAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("PSPath", null);
            cmdProc.AddParameter(null, "a path");

            cmdProc.BindArguments(null);

            Assert.AreEqual("File", cmdlet.ParameterSetName);
        }
コード例 #2
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingNonSwitch()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Name", null);
            cmdProc.AddParameter(null, "John");

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
            Assert.IsFalse(cmdlet.Recurse.ToBool());
        }
コード例 #3
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingCombinationNonDefaultSet()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Variable", "a");
            cmdProc.AddParameter("Recurse", null);

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
            Assert.AreEqual("a path", cmdlet.FilePath);
            Assert.IsTrue(cmdlet.Recurse.ToBool());
        }
コード例 #4
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingParameterSetSelectionDoubleShouldFail()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Variable", null);
            cmdProc.AddParameter(null, "test");
            cmdProc.AddParameter("FilePath", null);
            cmdProc.AddParameter(null, "a path");

            Assert.Throws(typeof(Exception), delegate()
            {
                cmdProc.BindArguments(null);
            });
        }
コード例 #5
0
        private void DelayedInternalInitialize()
        {
            this.pp = new PipelineProcessor();
            CmdletInfo       cmdletInfo       = new CmdletInfo(this.commandName, this.commandType, null, null, this.context);
            CommandProcessor commandProcessor = new CommandProcessor(cmdletInfo, this.context);

            foreach (CommandParameterInternal internal2 in this.commandParameterList)
            {
                commandProcessor.AddParameter(internal2);
            }
            this.pp.Add(commandProcessor);
        }
コード例 #6
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingAmbiguous()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("i", 10);

            Assert.Throws(typeof(ArgumentException), delegate() {
                cmdProc.BindArguments(null);
            });
        }
コード例 #7
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingParameterAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Path", "a path");

            cmdProc.BindArguments(null);

            Assert.AreEqual("a path", cmdlet.FilePath.ToString());
        }
コード例 #8
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingParameter()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("InputObject", 10);

            cmdProc.BindArguments(null);

            Assert.AreEqual("10", cmdlet.InputObject.ToString());
        }
コード例 #9
0
ファイル: BindingTests.cs プロジェクト: anton-gogolev/Pash
        public void BindingFieldAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("fn", "John");

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
        }
コード例 #10
0
        private void DelayedInternalInitialize()
        {
            _pp = new PipelineProcessor();

            CmdletInfo cmdletInfo = new CmdletInfo(_commandName, _commandType, null, null, _context);

            CommandProcessor cp = new CommandProcessor(cmdletInfo, _context);

            foreach (CommandParameterInternal par in _commandParameterList)
            {
                cp.AddParameter(par);
            }

            _pp.Add(cp);
        }
コード例 #11
0
ファイル: LocalPipeline.cs プロジェクト: modulexcite/pash-1
        private PipelineProcessor CreatePipelineProcessor()
        {
            PipelineProcessor processor2;
            CommandCollection commands = base.Commands;

            if ((commands == null) || (commands.Count == 0))
            {
                throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "NoCommandInPipeline", new object[0]);
            }
            PipelineProcessor processor = new PipelineProcessor {
                TopLevel = true
            };
            bool flag = false;

            try
            {
                foreach (Command command in commands)
                {
                    CommandProcessorBase base2;
                    if (command.CommandInfo == null)
                    {
                        base2 = command.CreateCommandProcessor(this.LocalRunspace.ExecutionContext, this.LocalRunspace.CommandFactory, base.AddToHistory, this.IsNested ? CommandOrigin.Internal : CommandOrigin.Runspace);
                    }
                    else
                    {
                        CmdletInfo commandInfo = (CmdletInfo)command.CommandInfo;
                        base2 = new CommandProcessor(commandInfo, this.LocalRunspace.ExecutionContext);
                        PSSQMAPI.IncrementData(commandInfo.CommandType);
                        base2.Command.CommandOriginInternal       = CommandOrigin.Internal;
                        base2.Command.MyInvocation.InvocationName = commandInfo.Name;
                        if (command.Parameters != null)
                        {
                            foreach (CommandParameter parameter in command.Parameters)
                            {
                                CommandParameterInternal internal2 = CommandParameter.ToCommandParameterInternal(parameter, false);
                                base2.AddParameter(internal2);
                            }
                        }
                    }
                    base2.RedirectShellErrorOutputPipe = base.RedirectShellErrorOutputPipe;
                    processor.Add(base2);
                }
                processor2 = processor;
            }
            catch (RuntimeException)
            {
                flag = true;
                throw;
            }
            catch (Exception exception)
            {
                flag = true;
                CommandProcessorBase.CheckForSevereException(exception);
                throw new RuntimeException(PipelineStrings.CannotCreatePipeline, exception);
            }
            finally
            {
                if (flag)
                {
                    base.SetHadErrors(true);
                    processor.Dispose();
                }
            }
            return(processor2);
        }