本文整理汇总了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);
}
示例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);
}
}
示例3: ResultReporter
public ResultReporter(XmlNode result, ConsoleOptions options)
{
this.result = result;
this.testRunResult = result.GetAttribute("result");
this.options = options;
this.summary = new ResultSummary(result);
}
示例4: Parse
public override void Parse(string[] args)
{
if (_consoleOptions == null) _consoleOptions = GetDefaultConsoleOptions();
if (_engineOptions == null) _engineOptions = GetDefaultEngineOptions();
base.Parse(args);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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());
}
}
}