public T Deserialize(string prefix, string contentType, ModelSerializationContext context, ModelMetadataProvider metadataProvider) { var serializer = JsonSerializer.Create(new JsonSerializerSettings()); var s = new StreamReader(context.InputStream).ReadLine(); return((T)serializer.Deserialize(new StreamReader(context.InputStream), typeof(T))); }
public void CreateSerializer_ForCollectionDefaultingToDefaultSerializer_UsesSpecificTypeSerializerIfExistent_DeserializationCase() { resolver.Register <Customer>(MimeType.JSon, typeof(StubSerializer <Customer>)); var serializer = resolver.CreateSerializer <IEnumerable <Customer> >(MimeType.JSon); var context = new ModelSerializationContext( new MemoryStream(Encoding.UTF8.GetBytes("[ {} ]")), new NameValueCollection()); var model = serializer.Deserialize("", "application/json", context, new StubModelMetadataProvider(null)); model.Should().NotBeNull(); model.Count().Should().Be(2); }
public void Init() { formValues = new NameValueCollection(); inputStream = new MemoryStream(); serializationContext = new ModelSerializationContext(inputStream, formValues); }
public Customer Deserialize(string prefix, string contentType, ModelSerializationContext request, ModelMetadataProvider metadataProvider) { throw new NotImplementedException(); }
public void Init() { formValues = new NameValueCollection(); inputStream = new MemoryStream(); serializationContext = new ModelSerializationContext(inputStream, formValues); }