Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.2 KiB

  1. /********************************************************************
  2. * Project : C:\DEPOT\multimedia\eHomeTest\UserXp\guidesearch\guidesearch.sln
  3. * File : ProgramArgs.cs
  4. * Summary :
  5. * Classes :
  6. * Notes :
  7. * *****************************************************************/
  8. using System;
  9. namespace MediaManager
  10. {
  11. /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
  12. * public class ProgramArgs
  13. *
  14. * Summary :
  15. * ---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C*/
  16. public class ProgramArgs
  17. {
  18. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  19. * static public int CommandLine(string[] args)
  20. * Args :
  21. * Modifies :
  22. * Returns :
  23. * M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M*/
  24. public bool CommandLine(string[] args)
  25. {
  26. if (args == null)
  27. {
  28. ProgramArgs.ArgsHelp();
  29. return false;
  30. }
  31. if ( args.GetLength(0) < NUMPARAMS )
  32. {
  33. ProgramArgs.ArgsHelp();
  34. return false;
  35. }
  36. // Command line -m<max len> -a"attribute" -o"output file" -p to append
  37. foreach(string s in args)
  38. {
  39. // attribute to measure
  40. if ( s.StartsWith("-a") && 2 < s.Length)
  41. {
  42. _attribute = s.Substring(2);
  43. }
  44. // Max allowed length of string
  45. else if ( s.StartsWith("-m") && 2 < s.Length)
  46. {
  47. _maxLen = System.Convert.ToInt32(s.Substring(2));
  48. }
  49. // output file - if any
  50. else if ( s.StartsWith("-o") && 2 < s.Length)
  51. {
  52. _outputFile = s.Substring(2);
  53. }
  54. else if ( s.StartsWith("-p" ))
  55. {
  56. _appendToFile = true;
  57. }
  58. else
  59. {
  60. Console.WriteLine("Invalid parameter!!");
  61. ArgsHelp();
  62. return false;
  63. }
  64. } // foreach
  65. return true;
  66. } // public int ProgramArgs(string[] args)
  67. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  68. * static private void ArgsHelp()
  69. * Args :
  70. * Modifies :
  71. * Returns :
  72. * M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M*/
  73. static private void ArgsHelp()
  74. {
  75. Console.WriteLine("MediaManager -a<attribute> -m<Max Length> -o<Output file> -p[append flag]");
  76. Console.WriteLine("\tAttribute can be any one of the attributes supported by media player.");
  77. Console.WriteLine("\tincluding: Name, Artist, Album, etc.");
  78. Console.WriteLine();
  79. Console.WriteLine("\tIf no output file is specified, data is written to console.");
  80. Console.WriteLine("\tIf the -p argument is given, output will be appended to specified file.");
  81. }
  82. /*---------------------------------------------------------
  83. Member Variables
  84. ----------------------------------------------------------*/
  85. // Required number of parameters
  86. public const int NUMPARAMS = 2;
  87. public int maxLen
  88. {
  89. get { return _maxLen;}
  90. set { _maxLen = value;}
  91. }
  92. public string attribute
  93. {
  94. get { return _attribute; }
  95. set { _attribute = value; }
  96. }
  97. public string outputFile
  98. {
  99. get { return _outputFile;}
  100. set { _outputFile = value;}
  101. }
  102. public bool append
  103. {
  104. get { return _appendToFile; }
  105. set { _appendToFile = value; }
  106. }
  107. int _maxLen = 25;
  108. string _attribute = "title";
  109. string _outputFile = "";
  110. bool _appendToFile = false;
  111. } // public class ProgramArgs
  112. } // namespace guidesearch