public void ShouldNotThrowWithNullValuesNoPrefix() { collection[null] = null; var deserializer = new NameValueDeserializer(); deserializer.Deserialize(collection, typeof(Customer)); }
public void NoRequestForPropertyShouldNotInstantiatePropertyNoPrefix() { collection["Id"] = "20"; collection["Phone.Number"] = "800-555-1212"; var deserializer = new NameValueDeserializer(); var emp = deserializer.Deserialize <Employee>(collection, "emp"); Assert.IsNotNull(emp, "Employee should not be null."); Assert.IsNotNull(emp.Phone, "Employee phone should not be null."); Assert.IsNull(emp.BatPhone, "Employee OtherPhones should be null because it was not in request parameters."); }
internal static object Deserialize(this NameValueDeserializer nvd, NameValueCollection collection, Type targetType) { return(nvd.Deserialize(collection, null, targetType)); }
internal static T Deserialize <T>(this NameValueDeserializer nvd, NameValueCollection collection) where T : new() { return((T)nvd.Deserialize(collection, null, typeof(T))); }
public void NoRequestForPropertyShouldNotInstantiatePropertyNoPrefix() { collection["Id"] = "20"; collection["Phone.Number"] = "800-555-1212"; var deserializer = new NameValueDeserializer(); var emp = deserializer.Deserialize<Employee>(collection, "emp"); Assert.IsNotNull(emp, "Employee should not be null."); Assert.IsNotNull(emp.Phone, "Employee phone should not be null."); Assert.IsNull(emp.BatPhone, "Employee OtherPhones should be null because it was not in request parameters."); }
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { NameValueCollection store = GetStore(controllerContext); return(_deserializer.Deserialize(store, Prefix, bindingContext.ModelType)); }