/// <summary> /// Validates the Table Object. /// </summary> /// <param name="table">A <see cref="Table"/> containing the database table information</param> /// <remarks>Tables may not have blank spaces inside the string, unless there is a valid table name character.</remarks> /// <returns></returns> protected bool ValidateTable(Table table) { // Remove any blanks from the string TableNameChar = TableNameChar.Trim(); // Validate Table Name Char (might not have more than two characters) if (TableNameChar.Length > 2) { return(false); } // Look for the separator inside it if (TableNameChar != "") { /* There is a table name char */ /* On this case, it's acceptable to have inner blank spaces */ if (TableNameChar.Length == 2) { // There is a begin / end character if ((table.Name.Contains(TableNameChar[0].ToString())) && (table.Name.Contains(TableNameChar[1].ToString()))) { /* There is a problem , the table name should not have the separator character inside it */ return(false); } } else { // There is only one character if (table.Name.Contains(TableNameChar[0].ToString())) { /* There is a problem , the table name should not have the separator character inside it */ return(false); } } } else { /* There is no table name char */ /* On this case, it's not acceptable to have inner blank spaces */ // Look for blank spaces if (table.Name.Contains(" ")) { /* There are blank spaces inside it, consider invalid */ return(false); } } // Everything is fine return(true); }
/// <summary> /// Validates the table information /// </summary> /// <param name="table">The <see cref="Table"/> to be formatted</param> protected virtual void ValidateTable(Table table) { // Remove any blanks from the string TableNameChar = TableNameChar.Trim(); // Validate Table Name Char (might not have more than two characters) if (TableNameChar.Length > 2) { throw new Exception($"'{nameof(TableNameChar)}' cannot have more than two characters. Current value is '{TableNameChar}'"); } // Look for the separator inside it if (TableNameChar != "") { /* There is a table name char */ /* On this case, it's acceptable to have inner blank spaces */ if (TableNameChar.Length == 2) { // There is a begin / end character if ((table.Name.Contains(TableNameChar[0].ToString())) && (table.Name.Contains(TableNameChar[1].ToString()))) { /* There is a problem , the table name should not have the separator character inside it */ throw new Exception($"Table name '{table.Name}' is invalid. A table cannot have the separator '{TableNameChar}' on it"); } } else { // There is only one character if (table.Name.Contains(TableNameChar[0].ToString())) { /* There is a problem , the table name should not have the separator character inside it */ throw new Exception($"Table name '{table.Name}' is invalid. A table cannot have the separator '{TableNameChar}' on it"); } } } else { /* There is no table name char */ /* On this case, it's not acceptable to have inner blank spaces */ // Look for blank spaces if (table.Name.Contains(" ")) { /* There are blank spaces inside it, consider invalid */ throw new Exception($"Table name '{table.Name}' is invalid. It contains blank spaces but the dialect for this database does not have a valid '{nameof(TableNameChar)}'"); } } }