mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-25 08:22:17 +00:00
Support for interpolated URLs
Implemented use of TypeConverters for requests and responses
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
using MTSC.Common.Http;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using MTSC.Common.Http;
|
||||
using MTSC.Common.Http.RoutingModules;
|
||||
|
||||
namespace MTSC.UnitTests.RoutingModules
|
||||
{
|
||||
public class SomeResponseConverter : IResponseConverter<SomeRoutingResponse>
|
||||
public class SomeResponseConverter : TypeConverter
|
||||
{
|
||||
public HttpResponse ConvertResponse(SomeRoutingResponse response)
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return new HttpResponse { StatusCode = HttpMessage.StatusCodes.OK };
|
||||
if (destinationType == typeof(SomeRoutingResponse))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (value is SomeRoutingResponse)
|
||||
{
|
||||
return new HttpResponse { StatusCode = HttpMessage.StatusCodes.OK };
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user