using System;
namespace RestEase
{
///
/// Attribute allowing interface-level, method-level, or parameter-level headers to be defined. See the docs for details
///
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
public sealed class HeaderAttribute : Attribute
{
///
/// Gets the Name of the header
///
public string Name { get; }
///
/// Gets the value of the header, if present
///
public string? Value { get; }
///
/// Gets or sets the format string used to format the value, if this is used as a variable header
/// (i.e. is null).
///
///
/// If this looks like a format string which can be passed to ,
/// (i.e. it contains at least one format placeholder), then this happens with the value passed as the first arg.
/// Otherwise, if the value implements , this is passed to the value's
/// method. Otherwise this is ignored.
/// Example values: "X2", "{0:X2}", "test{0}".
///
public string? Format { get; set; }
///
/// Initialises a new instance of the class
/// #
///
/// Name of the header
public HeaderAttribute(string name)
{
this.Name = name;
this.Value = null;
}
///
/// Initialises a new instance of the class
///
/// Name of the header
/// Value of the header
public HeaderAttribute(string name, string value)
{
this.Name = name;
this.Value = value;
}
}
}