public void AddAllowedOriginsFromAttributes() { var type = this.GetType(); var allowedOrigins = new List <Endpoint.AllowedOrigin>(); if (type.GetCustomAttributes(typeof(AllowedOriginAttribute)) is IEnumerable <Attribute> attrs) { foreach (var attr in attrs) { if (attr is AllowedOriginAttribute allowedAttr) { var allowedOrigin = new AllowedOrigin(allowedAttr.Origin, allowedAttr.Methods, allowedAttr.Headers); AddAllowedOrigin(allowedOrigin); } } } }
public void AddAllowedOrigin(AllowedOrigin allowedOrigin) { allowedOrigins.TryAdd(allowedOrigin.Origin, allowedOrigin); }
public AllowedOrigin(string origin, AllowedOrigin other) : this(origin, other.Methods, other.Headers) { Varies = false; }