public object Deserialize(IDeserializerContext context) { T instance = FastActivator <T> .Create(); if (context.IsEmptyElement) { context.Read(); return(instance); } if (!context.Read()) { return(instance); } while (context.NodeType != XmlNodeType.EndElement && context.NodeType != XmlNodeType.None) { if (context.NodeType == XmlNodeType.Element) { ReadProperty(context, instance); continue; } if (!context.Read()) { break; } } context.ExitElement(); return(instance); }
private void ReadItem(IDeserializerContext context, IDictionary <TKey, TValue> dictionary) { if (context.NodeType != XmlNodeType.Element || context.LocalName != "item") { throw new InvalidOperationException("Dictionary is not at an item element"); } context.Read(); object key = context.Deserialize(context.Namespace); object element = context.Deserialize(context.Namespace); if (context.NodeType != XmlNodeType.EndElement || context.LocalName != "item") { throw new InvalidOperationException("Dictionary is not at the end of an item"); } context.Read(); if (key != null) { dictionary.Add((TKey)key, (TValue)element); } }
private bool ListIsEmpty(IDeserializerContext context) { if (context.IsEmptyElement) { context.Read(); return(true); } return(false); }
private void MoveToFirstElement(IDeserializerContext context) { context.Read(); }
private void MovePastEndElement(IDeserializerContext context) { context.Read(); }