public void FindsHandlerForDirectType() { var table = new MediaTypeHandlerTable(); var actual = table.GetMediaTypeHandler(MediaType.Json); Assert.NotNull(actual); Assert.IsType<TestMediaTypeHandler>(actual); }
public void FindsHandlerForCustomTypeWithCharset() { var table = new MediaTypeHandlerTable(); var actual = table.GetMediaTypeHandler("application/vnd.test.towel+json; charset=utf-8"); Assert.NotNull(actual); Assert.IsType<TestMediaTypeHandler>(actual); }
public void FindsHandlerForCustomTypeWithCharset() { var table = new MediaTypeHandlerTable(); var actual = table.GetMediaTypeHandler("application/vnd.test.towel+json; charset=utf-8"); Assert.NotNull(actual); Assert.IsType <TestMediaTypeHandler>(actual); }
public void FindsHandlerForDirectType() { var table = new MediaTypeHandlerTable(); var actual = table.GetMediaTypeHandler(MediaType.Json); Assert.NotNull(actual); Assert.IsType <TestMediaTypeHandler>(actual); }
public void FindsHandlerForDirectTypeList() { var table = new MediaTypeHandlerTable(); string matchedType; var actual = table.GetMediaTypeHandler(new[] {"application/foo", MediaType.Json}, out matchedType); Assert.NotNull(actual); Assert.IsType<TestMediaTypeHandler>(actual); Assert.Equal(MediaType.Json, matchedType); }
public void FindsHandlerForCustomTypeList() { var table = new MediaTypeHandlerTable(); string matchedType; const string customType = "application/vnd.test.towel+json"; var actual = table.GetMediaTypeHandler(new[] {"application/foo", customType}, out matchedType); Assert.NotNull(actual); Assert.IsType<TestMediaTypeHandler>(actual); Assert.Equal(customType, matchedType); }
public void FindsHandlerForHal() { var table = new MediaTypeHandlerTable(); string matchedType; const string customType = "application/hal+json"; var actual = table.GetMediaTypeHandler(new[] {customType}, out matchedType); Assert.NotNull(actual); Assert.IsType<HalMediaTypeHandler>(actual); Assert.Equal(customType, matchedType); }
public void FindsHandlerForDirectTypeList() { var table = new MediaTypeHandlerTable(); string matchedType; var actual = table.GetMediaTypeHandler(new[] { "application/foo", MediaType.Json }, out matchedType); Assert.NotNull(actual); Assert.IsType <TestMediaTypeHandler>(actual); Assert.Equal(MediaType.Json, matchedType); }
public void FindsHandlerForHal() { var table = new MediaTypeHandlerTable(); string matchedType; const string customType = "application/hal+json"; var actual = table.GetMediaTypeHandler(new[] { customType }, out matchedType); Assert.NotNull(actual); Assert.IsType <HalMediaTypeHandler>(actual); Assert.Equal(customType, matchedType); }
public void FindsHandlerForCustomTypeList() { var table = new MediaTypeHandlerTable(); string matchedType; const string customType = "application/vnd.test.towel+json"; var actual = table.GetMediaTypeHandler(new[] { "application/foo", customType }, out matchedType); Assert.NotNull(actual); Assert.IsType <TestMediaTypeHandler>(actual); Assert.Equal(customType, matchedType); }
/// <summary> /// This method supports the framework directly and should not be used from your code /// </summary> /// <typeparam name="T">The input model type.</typeparam> /// <param name="context">The context.</param> /// <returns>The model de-serialized from the input stream.</returns> public static T Impl <T>(IContext context) { if (context.Request.InputStream.CanSeek && context.Request.InputStream.Length == 0) { return(default(T)); } var mediaTypeHandlerTable = new MediaTypeHandlerTable(); var mediaTypeHandler = mediaTypeHandlerTable.GetMediaTypeHandler(context.Request.GetContentType()); return(mediaTypeHandler.Read <T>(context.Request.InputStream).Result); }
/// <summary> /// This method supports the framework directly and should not be used from your code /// </summary> /// <typeparam name="T">The input model type.</typeparam> /// <param name="context">The context.</param> /// <returns>The model de-serialized from the input stream.</returns> public static T Impl <T>(IContext context) { if (context.Request.InputStream.Length == 0) { return(default(T)); } var mediaTypeHandlerTable = new MediaTypeHandlerTable(); var mediaTypeHandler = mediaTypeHandlerTable.GetMediaTypeHandler(context.Request.GetContentType()); return((T)mediaTypeHandler.Read(context.Request.InputStream, typeof(T))); }
/// <summary> /// This method supports the framework directly and should not be used from your code /// </summary> /// <typeparam name="T">The input model type.</typeparam> /// <param name="handler">The handler.</param> /// <param name="context">The context.</param> public static void Impl <T>(IInput <T> handler, IContext context) { if (context.Request.InputStream.Length == 0) { return; } var mediaTypeHandlerTable = new MediaTypeHandlerTable(); var mediaTypeHandler = mediaTypeHandlerTable.GetMediaTypeHandler(context.Request.GetContentType()); handler.Input = (T)mediaTypeHandler.Read(context.Request.InputStream, typeof(T)); }
/// <summary> /// This method supports the framework directly and should not be used from your code /// </summary> /// <typeparam name="T">The input model type.</typeparam> /// <param name="handler">The handler.</param> /// <param name="context">The context.</param> public static void Impl <T>(IInput <T> handler, IContext context) { if (context.Request.InputStream.CanSeek && context.Request.InputStream.Length == 0) { return; } var mediaTypeHandlerTable = new MediaTypeHandlerTable(); var mediaTypeHandler = mediaTypeHandlerTable.GetMediaTypeHandler(context.Request.GetContentType()); handler.Input = mediaTypeHandler.Read <T>(context.Request.InputStream).Result; }