static int Main(string[] args) { ProgramOptions opts = new ProgramOptions(); opts.ProcessArgs(args); if (opts.IsSqlInput) { if (opts.DbType == null) { opts.DbType = "mysql"; } ConnectionStringFormatter stringFormatter = null; try { stringFormatter = ConnectionStringFormatter.GetFormatter(opts.DbType); } catch (ArgumentException) { Console.Out.WriteLine("Invalid connection type."); return(1); } } else if (opts.IsXmlInput) { //TODO: } else { return(1); } return(0); }
/// <summary> /// /// </summary> /// <param name="connectionType"></param> /// <returns></returns> /// <exception cref="ArgumentException"> /// If the given <paramref name="connectionType"/> is not supported. /// </exception> public static ConnectionStringFormatter GetFormatter(string connectionType) { ConnectionStringFormatter formatter = null; if (formatters != null) { formatter = formatters[connectionType]; } if (formatter == null) { Type formatterType = formatterTypes[connectionType]; if (formatterType == null) { throw new ArgumentException(); } formatter = (ConnectionStringFormatter)Activator.CreateInstance(formatterType); if (formatters == null) { formatters = new Dictionary <string, ConnectionStringFormatter>(StringComparer.OrdinalIgnoreCase); } formatters.Add(connectionType, formatter); } return(formatter); }