/// <summary> /// Gets a application configuration settings from command-line arguments /// </summary> /// <param name="args">Command-line arguments</param> /// <returns>Application configuration settings</returns> private static AppConfiguration GetAppConfigurationFromArguments(string[] args) { var appConfig = new AppConfiguration { Mode = AppMode.Unknown }; if (args != null && args.Length > 0) { int argCount = args.Length; int lastArgIndex = argCount - 1; for (int argIndex = 0; argIndex < argCount; argIndex++) { string arg = args[argIndex]; if (arg.StartsWith("-") && arg.Length > 1) { string switchName = arg.Substring(1).ToUpperInvariant(); switch (switchName) { case "-HELP": case "H": case "?": SetAppMode(appConfig, AppMode.Help); break; case "-VERSION": case "V": SetAppMode(appConfig, AppMode.Version); break; case "-NAMESPACE": case "N": SetAppMode(appConfig, AppMode.Conversion); if (argIndex < lastArgIndex) { appConfig.Namespace = TrimQuotes(args[++argIndex]); } else { throw new AppUsageException( "`-n` or `--namespace` switch must be followed by resource namespace."); } break; case "-INTERNAL-ACCESS-MODIFIER": case "I": SetAppMode(appConfig, AppMode.Conversion); appConfig.InternalAccessModifier = true; break; default: SetAppMode(appConfig, AppMode.Conversion); appConfig.InputDirectory = TrimQuotes(arg); break; } } else if (arg == "/?") { SetAppMode(appConfig, AppMode.Help); } else { SetAppMode(appConfig, AppMode.Conversion); appConfig.InputDirectory = TrimQuotes(arg); } } } else { SetAppMode(appConfig, AppMode.Conversion); } return(appConfig); }
/// <summary> /// Constructs an instance of the command-line applicationfor converting the <code>.resx</code> files /// to the <code>.Designer.cs</code> files /// </summary> /// <param name="args">Command-line arguments</param> private App(string[] args) { _appConfig = GetAppConfigurationFromArguments(args); }