private bool OkToScript(SQLObjectType sot, string schema, string name) { bool answer = false; if (!sot.Script) { return(answer); } if (sot.SQLObjects.Count == 0) { answer = true; } else { foreach (SQLObject so in sot.SQLObjects) { SQLObjectAction soa = so.CheckAction(schema, name); if (soa == SQLObjectAction.MatchedAndDoNotScript) { answer = false; break; } else if (soa == SQLObjectAction.MatchedAndScript) { answer = true; break; } } } return(answer); }
public SQLObjectAction CheckAction(string schema, string name) { SQLObjectAction answer = SQLObjectAction.DidNotMatch; bool schemaMatch = false; if (_RegexExpression) { // if schema is not specified, then we will consider that as a don't care // what schema is, just accept whatever comes our way if (schema.Length == 0 || Schema.Length == 0) { schemaMatch = true; } else { if (Regex.IsMatch(schema, Schema)) { schemaMatch = true; } } if (schemaMatch && Regex.IsMatch(name, Name)) { if (Script) { answer = SQLObjectAction.MatchedAndScript; } else { answer = SQLObjectAction.MatchedAndDoNotScript; } } } else { // if schema is not specified, then we will consider that as a don't care // what schema is, just accept whatever comes our way if (schema.Length == 0 || Schema.Length == 0) { schemaMatch = true; } else { if (Schema.Equals(schema, StringComparison.CurrentCultureIgnoreCase)) { schemaMatch = true; } } if (schemaMatch && Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)) { if (Script) { answer = SQLObjectAction.MatchedAndScript; } else { answer = SQLObjectAction.MatchedAndDoNotScript; } } } return(answer); }