Class OverrideTypeReaderAttribute
Marks the Type to be read by the specified TypeReader.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public sealed class OverrideTypeReaderAttribute : Attribute
- Inheritance
-
objectAttributeOverrideTypeReaderAttribute
Examples
In this example, the TimeSpan will be read by a custom
TypeReader, FriendlyTimeSpanTypeReader, instead of the
Fluxer.Net.Commands.TimeSpanTypeReader
[Command("time")]
public Task GetTimeAsync([OverrideTypeReader(typeof(FriendlyTimeSpanTypeReader))]TimeSpan time)
=> ReplyAsync(time);
Remarks
This attribute will override the TypeReader to be used when parsing for the desired type in the command. This is useful when one wishes to use a particular TypeReader without affecting other commands that are using the same target type.
warning
If the given type reader does not inherit from TypeReader, an ArgumentException will be thrown.
Constructors
OverrideTypeReaderAttribute(Type)
public OverrideTypeReaderAttribute(Type overridenTypeReader)
Parameters
overridenTypeReaderTypeThe TypeReader to be used with the parameter.
Exceptions
- ArgumentException
The given
overridenTypeReaderdoes not inherit from TypeReader.
Properties
TypeReader
Gets the specified TypeReader of the parameter.
public Type TypeReader { get; }