Esempio n. 1
0
File: Cmd.cs Progetto: rlaneve/cmd
        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            if (!commands.Any())
            {
                result = null;
                return true;
            }

            var runOptions = new RunOptions(this);
            result = Runner.Run(runOptions);
            return true;
        }
Esempio n. 2
0
        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            var names = binder.CallInfo.ArgumentNames;
            var numberOfArguments = binder.CallInfo.ArgumentCount;
            var numberOfNames = names.Count;

            var allNames = Enumerable.Repeat<string>(null, numberOfArguments - numberOfNames).Concat(names);
            arguments.AddRange(allNames.Zip(args, (flag, value) => new Argument(flag, value)));

            var runOptions = new RunOptions(this);
            result = Runner.Run(runOptions);
            return true;
        }
Esempio n. 3
0
        public string Run(RunOptions runOptions)
        {
            var process = new Process
                        {
                            StartInfo =
                                {
                                    FileName = runOptions.Command,
                                    Arguments = runOptions.Arguments,
                                    UseShellExecute = false,
                                    RedirectStandardOutput = true
                                }
                        };
            process.Start();
            var output = process.StandardOutput.ReadToEnd();
            process.WaitForExit();

            return output;
        }
Esempio n. 4
0
        public string Run(RunOptions runOptions)
        {
            var process = new Process
            {
                StartInfo =
                {
                    FileName               = runOptions.Command,
                    Arguments              = runOptions.Arguments,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true
                }
            };

            process.Start();
            var output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            return(output);
        }