private static bool IsFormatSupported(SampleDirection sampleDirection, MediaTypeFormatter formatter, Type type) { switch (sampleDirection) { case SampleDirection.Request: return formatter.CanReadType(type); case SampleDirection.Response: return formatter.CanWriteType(type); } return false; }
private static object Read(MemoryStream ms, Type tSource, MediaTypeFormatter formatter) { bool f = formatter.CanReadType(tSource); Assert.True(f); object o = formatter.ReadFromStreamAsync(tSource, ms, content: null, formatterLogger: null).Result; Assert.True(tSource.IsAssignableFrom(o.GetType())); return o; }