当前位置: 首页>>代码示例>>C#>>正文


C# ConsoleOptions类代码示例

本文整理汇总了C#中ConsoleOptions的典型用法代码示例。如果您正苦于以下问题:C# ConsoleOptions类的具体用法?C# ConsoleOptions怎么用?C# ConsoleOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConsoleOptions类属于命名空间,在下文中一共展示了ConsoleOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static int Main(string[] args)
        {
            ConsoleOptions options;
            try {
                options = new ConsoleOptions(args);
            }
            catch (OptionException e) {
                Console.Error.Write("PhantomIis: ");
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine("Try `PhantomIis --help' for more information.");
                return -1;
            }

            if (options.DisplayVersion) {
                options.ShowVersion();
                return 0;
            }

            if (options.DisplayHelp) {
                options.ShowHelp();
                return 0;
            }

            List<string> validationErrors = options.Validate();
            if (validationErrors.Any()) {
                validationErrors.ForEach(Console.Error.WriteLine);
                return -1;
            }

            return (new Program()).Run(options);
        }
开发者ID:modulexcite,项目名称:PhantomIIS,代码行数:31,代码来源:Program.cs

示例2: Run

        /// <summary>
        /// Executes the comand line - depending upon the options provided we will
        /// either run a single file, a single command, or enter the interactive loop.
        /// </summary>
        public int Run(IScriptEngine engine, IConsole console, ConsoleOptions options) {
            Contract.RequiresNotNull(engine, "engine");
            Contract.RequiresNotNull(console, "console");
            Contract.RequiresNotNull(options, "options");

            _engine = engine;
            _options = options;
            _console = console;

            Initialize();
            
            try {
                return Run();

#if !SILVERLIGHT // ThreadAbortException.ExceptionState
            } catch (System.Threading.ThreadAbortException tae) {
                if (tae.ExceptionState is KeyboardInterruptException) {
                    Thread.ResetAbort();
                }
                return -1;
#endif
            } finally {
                Shutdown(engine);
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:29,代码来源:CommandLine.cs

示例3: ResultReporter

 public ResultReporter(XmlNode result, ConsoleOptions options)
 {
     this.result = result;
     this.testRunResult = result.GetAttribute("result");
     this.options = options;
     this.summary = new ResultSummary(result);
 }
开发者ID:madmurdock,项目名称:nunit-framework,代码行数:7,代码来源:ResultReporter.cs

示例4: Parse

        public override void Parse(string[] args)
        {
            if (_consoleOptions == null) _consoleOptions = GetDefaultConsoleOptions();
            if (_engineOptions == null) _engineOptions = GetDefaultEngineOptions();

            base.Parse(args);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:7,代码来源:DefaultOptionsParser.cs

示例5: Main

		public static int Main(string[] args)
		{
			options = new ConsoleOptions ();
			options.ProcessArgs (args);
			args = options.RemainingArguments;

			NUnit.Core.TestDomain domain = new NUnit.Core.TestDomain();

			if (args.Length < 1) {
				options.DoUsage ();
				return 1;
			}

			string assembly = args [0];
			Console.WriteLine ("ASSEMBLY: " + assembly);

			Test test;

			if (args.Length == 1)
				test = domain.LoadAssembly (assembly);
			else
				test = domain.LoadAssembly (assembly, args [1]);
			if (test == null) {
				Console.Error.WriteLine("\nERROR: Unable to load test suite from assembly {0}", assembly);
				return 1;
			}
				
			Directory.SetCurrentDirectory(new FileInfo(assembly).DirectoryName);
			string xmlResult = "result.xml";

			XmlTextReader reader = GetTransformReader();
			ConsoleUi consoleUi = new ConsoleUi(domain, xmlResult, reader);
			return consoleUi.Execute();
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:34,代码来源:nunit-console.cs

示例6: CanRecognizeBooleanOptions

        public void CanRecognizeBooleanOptions(string propertyName, string pattern)
        {
            string[] prototypes = pattern.Split('|');

            PropertyInfo property = GetPropertyInfo(propertyName);
            Assert.AreEqual(typeof(bool), property.PropertyType, "Property '{0}' is wrong type", propertyName);

            foreach (string option in prototypes)
            {
                ConsoleOptions options = new ConsoleOptions("-" + option);
                Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option);

                options = new ConsoleOptions("-" + option + "+");
                Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "+");

                options = new ConsoleOptions("-" + option + "-");
                Assert.AreEqual(false, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "-");

                options = new ConsoleOptions("--" + option);
                Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize --" + option);

                options = new ConsoleOptions("/" + option);
                Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize /" + option);
            }
        }
开发者ID:rbenhassine2,项目名称:nunit,代码行数:25,代码来源:CommandLineTests.cs

示例7: Main

        static void Main(string[] args)
        {
            var metadata = ExecutionEnvironment.GetApplicationMetadata();
            Log(metadata + "\r\n");

            var options = new ConsoleOptions(args);

            if (options.ShowHelp)
            {
                Console.WriteLine("Options:");
                options.OptionSet.WriteOptionDescriptions(Console.Out);
                Console.ReadKey();
                return;
            }

            AppAction appAction = null;

            switch (options.Mode)
            {
                case Mode.AllEvents:
                    appAction = new AllEventsDump();
                    break;
                case Mode.InterestingEvents:
                    appAction = new InterestingEventDump();
                    break;
            }

            appAction.Run();

            Log("Press enter to exit...");
            Console.ReadLine();
        }
开发者ID:neutmute,项目名称:clockwatcher,代码行数:32,代码来源:Program.cs

示例8: Run

        private void Run(string[] args)
        {
            // Creating this from static causes an exception in Raspian. Not in ubunti though?
            Log  = LogManager.GetCurrentClassLogger();
            var options = new ConsoleOptions(args);

            if (options.ShowHelp)
            {
                Console.WriteLine("Options:");
                options.OptionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            var deviceFactory = new Pca9685DeviceFactory();
            var device = deviceFactory.GetDevice(options.UseFakeDevice);
            var motorController = new PwmController(device);
            motorController.Init();

            Log.InfoFormat("RPi.Console running with {0}", options);

            switch (options.Mode)
            {
                case Mode.DcMotor:
                    RunDcMotor(motorController);
                    break;

                case Mode.Servo:
                    RunServo(motorController);
                    break;

                case Mode.Stepper:
                    motorController.Stepper.Rotate(600);
                    break;

                case Mode.Led:
                    RunLed(motorController);
                    break;

                case Mode.RawPwm:
                    RunRawPwm(device);
                    break;

                case Mode.AlarmClock:
                    var alarmClock = new AlarmClock(motorController);
                    alarmClock.Set(options.AlarmDate);
                    alarmClock.WaitForAlarm();
                    break;

                case Mode.SignalRTest:
                    var signalRConnection = new SignalRConnection(motorController);
                    signalRConnection.Run();
                    break;
            }

            motorController.AllStop();
            deviceFactory.Dispose();

            //http://nlog-project.org/2011/10/30/using-nlog-with-mono.html
           // NLog.LogManager.Configuration = null;
        }
开发者ID:Revex,项目名称:RPi.Demo,代码行数:60,代码来源:Program.cs

示例9: EditSettings

        public int EditSettings(ConsoleOptions options)
        {
            var settings = this.settingRepository.Load(options.SettingsFile);
            var message = string.Empty;

            this.consoleWriter
                .WriteLine()
                .WriteLine(Resources.SettingsEditorLaunching)
                .WriteLine(Resources.SettingsEditorCloseWarning);

            using (var viewModel = new SettingsViewModel(settings))
            {
                var view = this.viewFactory.CreateSettings(viewModel);
                var result = view.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    this.settingRepository.Save(settings, options.SettingsFile);

                    message = string.Format(Resources.SettingsEditorSavedFormat, options.SettingsFile);
                }
                else
                {
                    message = Resources.SettingsEditorCanceled;
                }
            }

            this.consoleWriter
                .WriteLine()
                .WriteLine(message);

            return 0;
        }
开发者ID:jkorell,项目名称:jslintnet,代码行数:33,代码来源:ConsoleJSLintProvider.cs

示例10: CreateConsole

 protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
 {
     var pyoptions = (PythonConsoleOptions) options;
     return pyoptions.BasicConsole
                ? new BasicConsole(options.ColorfulConsole)
                : new SuperConsole(commandLine, options.ColorfulConsole);
 }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:7,代码来源:PythonScriptConsole.cs

示例11: PythonConsoleWindow

        public PythonConsoleWindow()
        {
            Initialized += new EventHandler(MainWindow_Initialized);
            // Load our custom highlighting definition:
            IHighlightingDefinition pythonHighlighting;
            using (Stream s = typeof(PythonConsoleWindow).Assembly.GetManifestResourceStream("IronPythonConsole.Resources.Python.xshd"))
            {
                if (s == null)
                    throw new InvalidOperationException("Could not find embedded resource");
                using (XmlReader reader = new XmlTextReader(s))
                {
                    pythonHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                        HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            // and register it in the HighlightingManager
            HighlightingManager.Instance.RegisterHighlighting("Python Highlighting", new string[] { ".cool" }, pythonHighlighting);

            InitializeComponent();

            textEditor.SyntaxHighlighting = pythonHighlighting;

            textEditor.PreviewKeyDown += new KeyEventHandler(textEditor_PreviewKeyDown);

            consoleOptionsProvider = new ConsoleOptions(console.Pad);

            propertyGridComboBox.SelectedIndex = 0;

            expander.Expanded += new RoutedEventHandler(expander_Expanded);

            console.Pad.Host.ConsoleCreated +=new PythonConsoleControl.ConsoleCreatedEventHandler(Host_ConsoleCreated);
        }
开发者ID:rwg0,项目名称:ironlab,代码行数:32,代码来源:PythonConsoleWindow.xaml.cs

示例12: CreateConsole

 /// <remarks>
 /// After the engine is created the standard output is replaced with our custom Stream class so we
 /// can redirect the stdout to the text editor window.
 /// This can be done in this method since the Runtime object will have been created before this method
 /// is called.
 /// </remarks>
 protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
 {
     SetOutput(new PythonOutputStream(textEditor));
     pythonConsole = new PythonConsole(textEditor, commandLine);
     if (ConsoleCreated != null) ConsoleCreated(this, EventArgs.Empty);
     return pythonConsole;
 }
开发者ID:goutkannan,项目名称:ironlab,代码行数:13,代码来源:PythonConsoleHost.cs

示例13: run

        /******************************************************************************************
        ** Protected methods                                                                     **
        ******************************************************************************************/
        protected void run(string[] args)
        {
            long startTime = DateTime.Now.Ticks;

            // Load options from command-line arguments
            this.options = new ConsoleOptions(args);

            if (this.options.Paths.Length > 0) {
                // Output header if not running silent
                if (this.options.Verbose) {
                    WriteHeader();
                }

                Generator generator = new Generator(options);

                generator.OnProgress += new MessageHandler(this.generator_OnProgress);
                generator.OnWarning += new MessageHandler(this.generator_OnWarning);
                generator.OnError += new MessageHandler(this.generator_OnError);

                generator.generate();

                if (this.options.Verbose) {
                    TimeSpan interval = new TimeSpan(DateTime.Now.Ticks - startTime);
                    System.Console.WriteLine("Processed in " + interval.TotalSeconds + " seconds");
                }

            } else {
                this.options.DoHelp();
            }
        }
开发者ID:spjwebster,项目名称:asigen,代码行数:33,代码来源:Console.cs

示例14: CreateConsole

		/// <remarks>
		/// After the engine is created the standard output is replaced with our custom Stream class so we
		/// can redirect the stdout to the text editor window.
		/// This can be done in this method since the Runtime object will have been created before this method
		/// is called.
		/// </remarks>
		protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
		{
			ScriptingConsoleOutputStream stream = pythonConsole.CreateOutputStream();
			SetOutput(stream);
			pythonConsole.CommandLine = commandLine;
			return pythonConsole;
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:13,代码来源:PythonConsoleHost.cs

示例15: ProcessArgs

        private static void ProcessArgs(string[] args)
        {
            _logger.InfoFormat("Processing args: {0}", string.Join(",", args));

            var options = new ConsoleOptions();
            ICommandLineParser parser = new CommandLineParser();

            if (parser.ParseArguments(args, options) && args.Length > 0)
            {
                if (options.ScheduleBackupTasks)
                {
                    var scheduleEngine = ObjectFactory.GetInstance<IScheduleManager>();

                    scheduleEngine.ScheduleBackupTasks();
                }

                if (options.UnScheduleBackupTasks)
                {
                    var scheduleEngine = ObjectFactory.GetInstance<IScheduleManager>();

                    scheduleEngine.RemoveScheduledBackupTasks();
                }

                if (options.RunBackups)
                {
                    var backupManager = ObjectFactory.GetInstance<IBackupManager>();

                    backupManager.RunBackups();
                }

                if (options.Info)
                {
                    var configResourceAccess = ObjectFactory.GetInstance<IConfigResourceAccess>();

                    System.Console.WriteLine("Amount of days to keep backups: {0}", configResourceAccess.GetBackupRetentionDays());
                    System.Console.WriteLine("Press any key to continue...");
                    System.Console.ReadKey();
                }
            }
            else
            {
                System.Console.WriteLine(options.GetUsage());
            }

            if (!options.RunSilent)
            {
                System.Console.WriteLine("Input arg or Enter to exit.");

                var input = System.Console.ReadLine();

                if (!string.IsNullOrWhiteSpace(input))
                {
                    var newArgs = new List<string>();
                    newArgs.Add(input);

                    ProcessArgs(newArgs.ToArray());
                }
            }
        }
开发者ID:escherrer,项目名称:EC2Utilities,代码行数:59,代码来源:Program.cs


注:本文中的ConsoleOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。