public static string ToDebugString(
            [NotNull] this IReadOnlySequence sequence,
            MetadataDebugStringOptions options,
            int indent = 0)
        {
            var builder      = new StringBuilder();
            var indentString = new string(' ', indent);

            builder
            .Append(indentString)
            .Append("Sequence: ");

            if (sequence.Schema != null)
            {
                builder
                .Append(sequence.Schema)
                .Append(".");
            }

            builder.Append(sequence.Name);

            if (!sequence.IsCyclic)
            {
                builder.Append(" Cyclic");
            }

            if (sequence.StartValue != 1)
            {
                builder.Append(" Start: ")
                .Append(sequence.StartValue);
            }

            if (sequence.IncrementBy != 1)
            {
                builder.Append(" IncrementBy: ")
                .Append(sequence.IncrementBy);
            }

            if (sequence.MinValue != null)
            {
                builder.Append(" Min: ")
                .Append(sequence.MinValue);
            }

            if (sequence.MaxValue != null)
            {
                builder.Append(" Max: ")
                .Append(sequence.MaxValue);
            }

            if ((options & MetadataDebugStringOptions.SingleLine) == 0)
            {
                if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
                {
                    builder.Append(sequence.AnnotationsToDebugString(indent: indent + 2));
                }
            }

            return(builder.ToString());
        }
 /// <summary>
 ///     Constructs the event payload.
 /// </summary>
 /// <param name="eventDefinition"> The event definition. </param>
 /// <param name="messageGenerator"> A delegate that generates a log message for this event. </param>
 /// <param name="sequence"> The sequence. </param>
 public SequenceEventData(
     EventDefinitionBase eventDefinition,
     Func <EventDefinitionBase, EventData, string> messageGenerator,
     IReadOnlySequence sequence)
     : base(eventDefinition, messageGenerator)
 {
     Sequence = sequence;
 }
 private static void ValidateNamedSpecificSequence(IReadOnlySequence sequence)
 {
     Assert.Equal("Snook", sequence.Name);
     Assert.Null(sequence.Schema);
     Assert.Equal(11, sequence.IncrementBy);
     Assert.Equal(1729, sequence.StartValue);
     Assert.Equal(111, sequence.MinValue);
     Assert.Equal(2222, sequence.MaxValue);
     Assert.Same(typeof(int), sequence.Type);
 }
 private static void ValidateSchemaNamedSequence(IReadOnlySequence sequence)
 {
     Assert.Equal("Snook", sequence.Name);
     Assert.Equal("Tasty", sequence.Schema);
     Assert.Equal(1, sequence.IncrementBy);
     Assert.Equal(1, sequence.StartValue);
     Assert.Null(sequence.MinValue);
     Assert.Null(sequence.MaxValue);
     Assert.Same(typeof(long), sequence.Type);
 }
Exemple #5
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public static void SequenceConfiguredWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
            [NotNull] IReadOnlySequence sequence)
        {
            var definition = SqliteResources.LogSequenceConfigured(diagnostics);

            if (diagnostics.ShouldLog(definition))
            {
                definition.Log(diagnostics, sequence.Name);
            }

            if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
            {
                var eventData = new SequenceEventData(
                    definition,
                    SequenceConfiguredWarning,
                    sequence);

                diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
            }
        }