/// <summary>Parses a convention from a row.</summary> public static NamingConvention ParseFromRow(DataRow row, int nativeNameColumn = 0, int singularNameColumn = 1, int pluralNameColumn = 2) { var instance = new NamingConvention { NativeName = (string) row[nativeNameColumn], Singular = (string) row[singularNameColumn], Plural = (string) row[pluralNameColumn] }; return instance; }
/// <summary>Parses a convention from a row with well defined column names.</summary> public static NamingConvention ParseFromRow(DataRow row) { var instance = new NamingConvention { NativeName = (string) row["NativeName"], Singular = (string) row["Singular"], Plural = (string) row["Plural"] }; return instance; }
/// <summary>Parses a convention from a character delimited string.</summary> /// <param name="line">The line must match the following convention: {NativeName};{TableClassName};{TableRowName};{TablePropertyName}</param> /// <param name="delimiter">The delimiter between each property</param> public static NamingConvention ParseFromLine(string line, string delimiter) { var properties = Regex.Split(line, delimiter); if (properties.Length < 3) throw new InvalidOperationException($"The string '{line}' could not be parsed into an instance of {typeof (NamingConvention).Name}"); var instance = new NamingConvention { NativeName = properties[0], Singular = properties[1], Plural = properties[2] }; return instance; }