-
Notifications
You must be signed in to change notification settings - Fork 8
Parameter resolving attributes
Mattias Nordqvist edited this page Apr 18, 2015
·
5 revisions
You can implement your own attributes to decorate your parameters. Fact is, that the Alias attribute is implemented in the same way as any other custom attribute would be.
public class AliasAttribute : ParameterResolverAttribute
{
private readonly string _alias;
public AliasAttribute(string alias)
{
_alias = alias;
}
public override void Resolve(Parameter parameter)
{
parameter.Name = _alias;
}
}
The key is to extend the ParameterResolverAttribute and implement the Resolve method. The resolve method is then able to modify the parameter sent into it. There are two properties that you can modify to change how the url parameter is rendered. Name and Value. Name will translate to the part to the left of the equals-sign, while Value is the value to the right off the equals-sign. If the parameter is an url segment, then the Name property is not really of any interest.
- Getting started
- Basics (Http GET & Base Location)
- Basics pt. 2 (POST/PUT/DELETE, HttpResponseMessage, Exceptions, HttpClient, IDisposable)
- Building an HttpRequestMessage
- Parameter attributes
- Handling responses
- ApiSettings
- Typical setup (Develop/Test/Production & Mocking)
- Logging
- Testing
- Generic Api
- Multipart