|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Linq; |
| 3 | +using System.Reflection; |
| 4 | + |
| 5 | +namespace Palmmedia.ReportGenerator.Core |
| 6 | +{ |
| 7 | + /// <summary> |
| 8 | + /// Name of the command line arguments. |
| 9 | + /// </summary> |
| 10 | + internal static class CommandLineArgumentNames |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// The reports. |
| 14 | + /// </summary> |
| 15 | + public const string Reports = "REPORTS"; |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// The target directory. |
| 19 | + /// </summary> |
| 20 | + public const string TargetDirectory = "TARGETDIR"; |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// The source directories. |
| 24 | + /// </summary> |
| 25 | + public const string SourceDirectories = "SOURCEDIRS"; |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// The history directory. |
| 29 | + /// </summary> |
| 30 | + public const string HistoryDirectory = "HISTORYDIR"; |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// The report types. |
| 34 | + /// </summary> |
| 35 | + public const string ReportTypes = "REPORTTYPES"; |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Single report type (deprecated). |
| 39 | + /// </summary> |
| 40 | + public const string ReportType = "REPORTTYPE"; |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// The plugins. |
| 44 | + /// </summary> |
| 45 | + public const string Plugins = "PLUGINS"; |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// The assembly filters. |
| 49 | + /// </summary> |
| 50 | + public const string AssemblyFilters = "ASSEMBLYFILTERS"; |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// The assembly filters (deprecated). |
| 54 | + /// </summary> |
| 55 | + public const string Filters = "FILTERS"; |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Single class filter. |
| 59 | + /// </summary> |
| 60 | + public const string ClassFilters = "CLASSFILTERS"; |
| 61 | + |
| 62 | + /// <summary> |
| 63 | + /// The file filters. |
| 64 | + /// </summary> |
| 65 | + public const string FileFilters = "FILEFILTERS"; |
| 66 | + |
| 67 | + /// <summary> |
| 68 | + /// The verbosity. |
| 69 | + /// </summary> |
| 70 | + public const string Verbosity = "VERBOSITY"; |
| 71 | + |
| 72 | + /// <summary> |
| 73 | + /// The title. |
| 74 | + /// </summary> |
| 75 | + public const string Title = "TITLE"; |
| 76 | + |
| 77 | + /// <summary> |
| 78 | + /// The tag. |
| 79 | + /// </summary> |
| 80 | + public const string Tag = "TAG"; |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// All valid command line parameter names. |
| 84 | + /// </summary> |
| 85 | + private static readonly HashSet<string> ValidNames = new HashSet<string>( |
| 86 | + typeof(CommandLineArgumentNames) |
| 87 | + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) |
| 88 | + .Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(string)) |
| 89 | + .Select(x => (string)x.GetRawConstantValue()) |
| 90 | + .ToList()); |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// Gets a value indicating whether a command line parameter name is valid. |
| 94 | + /// </summary> |
| 95 | + /// <param name="name">The command line parameter name.</param> |
| 96 | + /// <returns><c>true</c> if command line parameter is valid; otherwise <c>false</c>.</returns> |
| 97 | + public static bool IsValid(string name) |
| 98 | + { |
| 99 | + if (name == null) |
| 100 | + { |
| 101 | + return false; |
| 102 | + } |
| 103 | + |
| 104 | + return ValidNames.Contains(name.ToUpperInvariant()); |
| 105 | + } |
| 106 | + } |
| 107 | +} |
0 commit comments