private Option <Uri> GetSynonymTargetUrl(Identifier identifier, SynonymTargets targets) { if (targets.Tables.ContainsKey(identifier)) { return(new Uri(UrlRouter.GetTableUrl(identifier), UriKind.Relative)); } if (targets.Views.ContainsKey(identifier)) { return(new Uri(UrlRouter.GetViewUrl(identifier), UriKind.Relative)); } if (targets.Sequences.ContainsKey(identifier)) { return(new Uri(UrlRouter.GetSequenceUrl(identifier), UriKind.Relative)); } if (targets.Synonyms.ContainsKey(identifier)) { return(new Uri(UrlRouter.GetSynonymUrl(identifier), UriKind.Relative)); } if (targets.Routines.ContainsKey(identifier)) { return(new Uri(UrlRouter.GetRoutineUrl(identifier), UriKind.Relative)); } return(Option <Uri> .None); }
public Routine(Identifier routineName) { if (routineName == null) { throw new ArgumentNullException(nameof(routineName)); } Name = routineName.ToVisibleName(); RoutineUrl = UrlRouter.GetRoutineUrl(routineName); }
private IReadOnlyCollection <Link> GetReferenceTargetLinks(string rootPath, Identifier objectName, Identifier referenceName) { if (rootPath == null) { throw new ArgumentNullException(nameof(rootPath)); } if (objectName == null) { throw new ArgumentNullException(nameof(objectName)); } if (referenceName == null) { throw new ArgumentNullException(nameof(referenceName)); } var qualifiedReference = QualifyReferenceName(objectName, referenceName); var isSelfReference = string.Equals(objectName.Schema, qualifiedReference.Schema, StringComparison.OrdinalIgnoreCase) && string.Equals(objectName.LocalName, qualifiedReference.LocalName, StringComparison.OrdinalIgnoreCase); if (isSelfReference) { return(Array.Empty <Link>()); } var result = new List <Link>(); var matchingTables = GetMatchingObjects(TableNames, qualifiedReference) .Select(name => new Link(name, new Uri(rootPath + UrlRouter.GetTableUrl(name), UriKind.Relative))); result.AddRange(matchingTables); var matchingViews = GetMatchingObjects(ViewNames, qualifiedReference) .Select(name => new Link(name, new Uri(rootPath + UrlRouter.GetViewUrl(name), UriKind.Relative))); result.AddRange(matchingViews); var matchingSequences = GetMatchingObjects(SequenceNames, qualifiedReference) .Select(name => new Link(name, new Uri(rootPath + UrlRouter.GetSequenceUrl(name), UriKind.Relative))); result.AddRange(matchingSequences); var matchingSynonyms = GetMatchingObjects(SynonymNames, qualifiedReference) .Select(name => new Link(name, new Uri(rootPath + UrlRouter.GetSynonymUrl(name), UriKind.Relative))); result.AddRange(matchingSynonyms); var matchingRoutines = GetMatchingObjects(RoutineNames, qualifiedReference) .Select(name => new Link(name, new Uri(rootPath + UrlRouter.GetRoutineUrl(name), UriKind.Relative))); result.AddRange(matchingRoutines); return(result); }
protected override IRuleMessage BuildRoutineMessage(Identifier routineName) { if (routineName == null) { throw new ArgumentNullException(nameof(routineName)); } var routineUrl = UrlRouter.GetRoutineUrl(routineName); var routineLink = $"<a href=\"{ routineUrl }\">{ HttpUtility.HtmlEncode(routineName.ToVisibleName()) }</a>"; var messageText = $"The routine { routineLink } contains whitespace and requires quoting to be used. Consider renaming to remove any whitespace."; return(new RuleMessage(RuleId, RuleTitle, Level, messageText)); }
protected override IRuleMessage BuildRoutineMessage(Identifier routineName) { if (routineName == null) { throw new ArgumentNullException(nameof(routineName)); } var routineUrl = UrlRouter.GetRoutineUrl(routineName); var routineLink = $"<a href=\"{ routineUrl }\">{ HttpUtility.HtmlEncode(routineName.ToVisibleName()) }</a>"; var messageText = $"The routine { routineLink } is also a database keyword and may require quoting to be used. Consider renaming to a non-keyword name."; return(new RuleMessage(RuleId, RuleTitle, Level, messageText)); }