Exemple #1
0
        private object DeserializeValue(EventReader reader, Type expectedType, DeserializationContext context)
        {
            if (reader.Accept <AnchorAlias>())
            {
                return(context.Anchors[reader.Expect <AnchorAlias>().Value]);
            }

            NodeEvent nodeEvent = (NodeEvent)reader.Parser.Current;

            if (nodeEvent.Tag == "tag:yaml.org,2002:null")
            {
                reader.Expect <NodeEvent>();
                AddAnchoredObject(nodeEvent, null, context.Anchors);
                return(null);
            }

            object result = DeserializeValueNotNull(reader, context, nodeEvent, expectedType);

            return(ObjectConverter.Convert(result, expectedType));
        }
Exemple #2
0
        private object DeserializeValue(EventReader reader, Type expectedType, object context)
        {
            if (reader.Accept <AnchorAlias>())
            {
                throw new NotImplementedException();
                //return context.Anchors[reader.Expect<AnchorAlias>().Value];
            }

            var nodeEvent = (NodeEvent)reader.Parser.Current;

            if (IsNull(nodeEvent))
            {
                reader.Expect <NodeEvent>();
                AddAnchoredObject(nodeEvent, null, context.Anchors);
                return(null);
            }

            object result = DeserializeValueNotNull(reader, context, nodeEvent, expectedType);

            return(ObjectConverter.Convert(result, expectedType));
        }