CommandLinePreferences.cs
上传用户:huiyue
上传日期:2022-04-08
资源大小:1429k
文件大小:2k
源码类别:

搜索引擎

开发平台:

ASP/ASPX

  1. using System;
  2. using Searcharoo.Common;
  3. using Mono.GetOptions;
  4. namespace Searcharoo.Indexer
  5. {
  6.     public class CommandLinePreferences : Mono.GetOptions.Options
  7.     {
  8.         #region private
  9.         private int _VerbosityLevel = 3;
  10.         private string _LogFileName = "";
  11.         #endregion
  12.         #region ctor
  13.         public CommandLinePreferences()
  14.         {
  15.             this.ParsingMode = OptionsParsingMode.Both;
  16.         }
  17.         #endregion
  18.         [Option("Verbosity level [1-5]", 'v', "verbosity")]
  19.         public int Verbosity
  20.         {
  21.             get
  22.             { return _VerbosityLevel; }
  23.             set
  24.             {
  25.                 _VerbosityLevel = value;
  26.                 Console.WriteLine("Verbosity was set to : " + _VerbosityLevel);
  27.             }
  28.         }
  29.         [Option("Log file name", 'l', "log")]
  30.         public string LogFileName
  31.         {
  32.             get
  33.             { return _LogFileName; }
  34.             set
  35.             {
  36.                 _LogFileName = value;
  37.                 Console.WriteLine("LogFileName was set to : " + _LogFileName);
  38.             }
  39.         }
  40.         [Option("Show usage syntax", 'u', "usage")]
  41.         public override WhatToDoNext DoUsage()
  42.         {
  43.             base.DoUsage();
  44.             return WhatToDoNext.AbandonProgram; //WhatToDoNext.GoAhead;
  45.         }
  46.         public override WhatToDoNext DoHelp() // uses parent's OptionAttribute as is
  47.         {
  48.             base.DoHelp();
  49.             return WhatToDoNext.AbandonProgram; //WhatToDoNext.GoAhead;
  50.         }
  51.     }
  52. }