public static void AddElementChangedResult <T>(this IChangeResultAggregator aggregator,
                                                       SemVerChangeType changeType,
                                                       ItemMatch <T> match,
                                                       IMessageFormatter messageFormatter,
                                                       FormatArguments arguments)
            where T : IItemDefinition
        {
            aggregator       = aggregator ?? throw new ArgumentNullException(nameof(aggregator));
            match            = match ?? throw new ArgumentNullException(nameof(match));
            messageFormatter = messageFormatter ?? throw new ArgumentNullException(nameof(messageFormatter));
            arguments        = arguments ?? throw new ArgumentNullException(nameof(arguments));

            var message = messageFormatter.FormatItemChangedMessage(match, arguments);

            var result = new ComparisonResult(
                changeType,
                match.OldItem, match.NewItem,
                message);

            aggregator.AddResult(result);
        }
示例#2
0
        public virtual string FormatItemChangedMessage <T>(ItemMatch <T> match, FormatArguments arguments)
            where T : IItemDefinition
        {
            match     = match ?? throw new ArgumentNullException(nameof(match));
            arguments = arguments ?? throw new ArgumentNullException(nameof(arguments));

            var definitionType = FormatDefinitionType(match);
            var identifier     = FormatIdentifier(match, arguments.Identifier);
            var oldValue       = FormatOldValue(match, arguments.OldValue);
            var newValue       = FormatNewValue(match, arguments.NewValue);

            ValidateMessageMarkers(arguments);

            // The message format is expected to have markers for each of the above values
            var message = arguments.MessageFormat
                          .Replace("{DefinitionType}", definitionType)
                          .Replace("{Identifier}", identifier)
                          .Replace("{OldValue}", oldValue)
                          .Replace("{NewValue}", newValue);

            return(message);
        }
示例#3
0
 protected virtual string FormatDefinitionType <T>(ItemMatch <T> match) where T : IItemDefinition
 {
     return(FormatDefinitionType(match.OldItem));
 }
示例#4
0
 private string FormatOldValue <T>(ItemMatch <T> match, string?value) where T : IItemDefinition
 {
     return(FormatOldValue(match.OldItem, value));
 }
示例#5
0
 protected virtual string FormatIdentifier <T>(ItemMatch <T> match, string identifier) where T : IItemDefinition
 {
     return(FormatIdentifier(match.OldItem, identifier));
 }