22 lines
789 B
C#
22 lines
789 B
C#
namespace SimpleHttpServer.Types;
|
|
|
|
/// <summary>
|
|
/// Specifies the name of a http endpoint parameter. If this attribute is not specified, the variable name is used instead.
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
|
|
public sealed class ParameterAttribute : Attribute {
|
|
// See the attribute guidelines at
|
|
// http://go.microsoft.com/fwlink/?LinkId=85236
|
|
|
|
public string Name { get; }
|
|
public bool IsOptional { get; }
|
|
public ParameterAttribute(string name, bool isOptional = false) {
|
|
if (string.IsNullOrWhiteSpace(name)) {
|
|
throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name));
|
|
}
|
|
|
|
Name = name;
|
|
IsOptional = isOptional;
|
|
}
|
|
}
|