Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
            public Sequence(
                Identifier sequenceName,
                decimal start,
                decimal increment,
                Option <decimal> minValue,
                Option <decimal> maxValue,
                int cache,
                bool cycle
                )
            {
                if (sequenceName == null)
                {
                    throw new ArgumentNullException(nameof(sequenceName));
                }

                Name        = sequenceName.ToVisibleName();
                SequenceUrl = UrlRouter.GetSequenceUrl(sequenceName);

                Start        = start;
                Increment    = increment;
                MinValueText = minValue.Match(mv => mv.ToString(), () => string.Empty);
                MaxValueText = maxValue.Match(mv => mv.ToString(), () => string.Empty);
                Cache        = cache;
                CycleText    = cycle ? "✓" : "✗";
            }
Ejemplo n.º 3
0
        protected override IRuleMessage BuildSequenceMessage(Identifier sequenceName)
        {
            if (sequenceName == null)
            {
                throw new ArgumentNullException(nameof(sequenceName));
            }

            var sequenceUrl  = UrlRouter.GetSequenceUrl(sequenceName);
            var sequenceLink = $"<a href=\"{ sequenceUrl }\">{ HttpUtility.HtmlEncode(sequenceName.ToVisibleName()) }</a>";
            var messageText  = $"The sequence { sequenceLink } contains whitespace and requires quoting to be used. Consider renaming to remove any whitespace.";

            return(new RuleMessage(RuleId, RuleTitle, Level, messageText));
        }
Ejemplo n.º 4
0
        protected override IRuleMessage BuildSequenceMessage(Identifier sequenceName)
        {
            if (sequenceName == null)
            {
                throw new ArgumentNullException(nameof(sequenceName));
            }

            var sequenceUrl  = UrlRouter.GetSequenceUrl(sequenceName);
            var sequenceLink = $"<a href=\"{ sequenceUrl }\">{ HttpUtility.HtmlEncode(sequenceName.ToVisibleName()) }</a>";
            var messageText  = $"The sequence { sequenceLink } 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));
        }
Ejemplo n.º 5
0
        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);
        }