Class ValueSourceAttribute

Overrides the default binding behavior for a typed handler request property.

Inheritance
object
Attribute
ValueSourceAttribute
Inherited Members
Attribute.GetCustomAttributes(MemberInfo, Type)
Attribute.GetCustomAttributes(MemberInfo, Type, bool)
Attribute.GetCustomAttributes(MemberInfo)
Attribute.GetCustomAttributes(MemberInfo, bool)
Attribute.IsDefined(MemberInfo, Type)
Attribute.IsDefined(MemberInfo, Type, bool)
Attribute.GetCustomAttribute(MemberInfo, Type)
Attribute.GetCustomAttribute(MemberInfo, Type, bool)
Attribute.GetCustomAttributes(ParameterInfo)
Attribute.GetCustomAttributes(ParameterInfo, Type)
Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
Attribute.GetCustomAttributes(ParameterInfo, bool)
Attribute.IsDefined(ParameterInfo, Type)
Attribute.IsDefined(ParameterInfo, Type, bool)
Attribute.GetCustomAttribute(ParameterInfo, Type)
Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
Attribute.GetCustomAttributes(Module, Type)
Attribute.GetCustomAttributes(Module)
Attribute.GetCustomAttributes(Module, bool)
Attribute.GetCustomAttributes(Module, Type, bool)
Attribute.IsDefined(Module, Type)
Attribute.IsDefined(Module, Type, bool)
Attribute.GetCustomAttribute(Module, Type)
Attribute.GetCustomAttribute(Module, Type, bool)
Attribute.GetCustomAttributes(Assembly, Type)
Attribute.GetCustomAttributes(Assembly, Type, bool)
Attribute.GetCustomAttributes(Assembly)
Attribute.GetCustomAttributes(Assembly, bool)
Attribute.IsDefined(Assembly, Type)
Attribute.IsDefined(Assembly, Type, bool)
Attribute.GetCustomAttribute(Assembly, Type)
Attribute.GetCustomAttribute(Assembly, Type, bool)
Attribute.Equals(object)
Attribute.GetHashCode()
Attribute.Match(object)
Attribute.IsDefaultAttribute()
Attribute.TypeId
object.GetType()
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: NanoRoute
Assembly: NanoRoute.dll
Syntax
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class ValueSourceAttribute : Attribute
Examples
public sealed class UserRequest
{
    [ValueSource(ValueSource.Parameter, Name = "user_id")]
    public int Id { get; init; }
}

Constructors

ValueSourceAttribute(ValueSource)

Overrides the default binding behavior for a typed handler request property.

Declaration
public ValueSourceAttribute(ValueSource source)
Parameters
Type Name Description
ValueSource source

The source used to populate the annotated property.

Examples
public sealed class UserRequest
{
    [ValueSource(ValueSource.Parameter, Name = "user_id")]
    public int Id { get; init; }
}

Properties

Name

Gets or sets an optional binding name.

Declaration
public string? Name { get; init; }
Property Value
Type Description
string
Remarks

For Parameter, this overrides the key looked up in Parameters. For ServiceLocator, this is treated as the keyed service name. Skip does not allow a name because no value is read.

Examples
[ValueSource(ValueSource.Parameter, Name = "user_id")]
public int Id { get; init; }
Exceptions
Type Condition
InvalidOperationException

Thrown when a name is assigned while Source is Skip.

Source

Gets the binding source used for the annotated property.

Declaration
public ValueSource Source { get; }
Property Value
Type Description
ValueSource
In this article
Back to top Generated by DocFX