public void FindProperty_FindsIgnoredProperties() { SerializationContext context = new SerializationContext(); TypeData handler = context.GetTypeHandler(typeof(IgnoredFieldClass)); IPropertyData fieldHandler = handler.FindProperty("IVal"); Assert.IsNotNull(fieldHandler, "Ignored property not found"); }
public void IgnoreProperty_DoesNotDeleteField() { SerializationContext context = new SerializationContext(); TypeData handler = context.GetTypeHandler(typeof(SimpleObject)); foreach(IPropertyData prop in handler.AllProperties) ; // force properties to load handler.IgnoreProperty("IntValue"); bool found = false; foreach (IPropertyData prop in handler.AllProperties) if (prop.Name == "IntValue") found = true; Assert.IsTrue(found, "Ignored property deleted"); }
public void AttributeProcessors_CustomProcessor_XmlIgnore() { SerializationContext context = new SerializationContext(); context.TypeHandlerFactory.AttributeProcessors.Add(new XmlIgnoreAttributeProcessor()); TypeData handler = context.GetTypeHandler(typeof(XmlIgnoreMock)); Assert.IsTrue(handler.FindProperty("Salary").Ignored, "XmlIgnore attribute not ignored"); }
public void IgnoreProperty_WhenFieldDoesntExist_ThrowsError() { SerializationContext context = new SerializationContext(); TypeData handler = context.GetTypeHandler(typeof(SimpleObject)); handler.IgnoreProperty("Foo"); }