/// <summary> /// Initializes a new instance of the <see cref="LongJsonContentMiddleware"/> class. /// </summary> /// <param name="jsonModifier">JSON content modifier.</param> /// <param name="configuration">The key/value application configuration properties.</param> public LongJsonContentMiddleware(IJsonStreamModifier jsonModifier, IConfiguration?configuration) { _jsonModifier = jsonModifier; if (configuration is not null) { MaxCharCountInField = configuration.GetValue(MaxCharCountInFieldSectionKey, 500); LeaveOnTrim = configuration.GetValue(LeaveOnTrimSectionKey, 10); } }
/// <summary> /// Initializes a new instance of the <see cref="LongJsonContentMiddleware"/> class. /// </summary> /// <param name="jsonModifier">JSON content modifier.</param> /// <param name="maxCharCountInField">The maximum character count in field.</param> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="maxCharCountInField"/> is less than 1. /// </exception> public LongJsonContentMiddleware(IJsonStreamModifier jsonModifier, int maxCharCountInField) : this(jsonModifier, null) { if (maxCharCountInField < 1) { throw new ArgumentOutOfRangeException(nameof(maxCharCountInField)); } MaxCharCountInField = maxCharCountInField; }