using System; using System.Collections.Generic; namespace RestEase.Implementation { /// /// Class containing information about a desired header parameter /// public abstract class HeaderParameterInfo { /// /// Serialize the value into a name -> value pair using its ToString method /// /// given to the , if any /// Serialized value public abstract KeyValuePair SerializeToString(IFormatProvider? formatProvider); } /// /// Class containing information about a desired header parameter /// /// Type of the value public class HeaderParameterInfo : HeaderParameterInfo { private readonly string name; private readonly T value; private readonly string? defaultValue; private readonly string? format; /// /// Initialises a new instance of the class /// /// Name of the header /// Value of the header /// Default value of the header, used if is null /// public HeaderParameterInfo(string name, T value, string? defaultValue, string? format) { this.name = name; this.value = value; this.defaultValue = defaultValue; this.format = format; } /// /// Serialize the value into a name -> value pair using its ToString method /// /// given to the , if any /// Serialized value public override KeyValuePair SerializeToString(IFormatProvider? formatProvider) { string? value = this.defaultValue; if (this.value != null) value = ToStringHelper.ToString(this.value, this.format, formatProvider); return new KeyValuePair(this.name, value); } } }