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); }
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 BuildSynonymMessage(Identifier synonymName) { if (synonymName == null) { throw new ArgumentNullException(nameof(synonymName)); } var synonymUrl = UrlRouter.GetSynonymUrl(synonymName); var synonymLink = $"<a href=\"{ synonymUrl }\">{ HttpUtility.HtmlEncode(synonymName.ToVisibleName()) }</a>"; var messageText = $"The synonym { synonymLink } contains whitespace and requires quoting to be used. Consider renaming to remove any whitespace."; return(new RuleMessage(RuleId, RuleTitle, Level, messageText)); }
public Synonym(Identifier synonymName, Identifier target, Option <Uri> targetUrl) { if (synonymName == null) { throw new ArgumentNullException(nameof(synonymName)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } Name = synonymName.ToVisibleName(); SynonymUrl = UrlRouter.GetSynonymUrl(synonymName); var targetName = target.ToVisibleName(); TargetText = targetUrl.Match( uri => $"<a href=\"{ uri }\">{ HttpUtility.HtmlEncode(targetName) }</a>", () => HttpUtility.HtmlEncode(targetName) ); }