예제 #1
0
        public XmlReaderDelegator(XmlReader reader)
        {
            ArgumentNullException.ThrowIfNull(reader);

            this.reader           = reader;
            this.dictionaryReader = reader as XmlDictionaryReader;
        }
    public void XmlDictionaryWriterReaderNonGenericNullTest()
    {
        TestModel?          testModel = null;
        XmlDictionaryWriter?write     = null;
        XmlDictionaryReader?reader    = null;

        testModel.Serialize(typeof(TestModel), write);
        write.WriteXml(typeof(TestModel), testModel);
        reader.ReadXml(typeof(TestModel));
    }
예제 #3
0
    public void XmlDictionaryWriterReaderNullTest()
    {
        TestModel?          testModel = null;
        XmlDictionaryWriter?write     = null;
        XmlDictionaryReader?reader    = null;

        testModel.Serialize(write);
        write.WriteXml(testModel);
        reader.ReadXml <TestModel>();
    }
예제 #4
0
        public override void WriteNode(XmlReader reader, bool defattr)
        {
            XmlDictionaryReader?dictionaryReader = reader as XmlDictionaryReader;

            if (dictionaryReader != null)
            {
                WriteNode(dictionaryReader, defattr);
            }
            else
            {
                base.WriteNode(reader, defattr);
            }
        }
예제 #5
0
 public XmlReaderDelegator(XmlReader reader)
 {
     XmlObjectSerializer.CheckNull(reader, nameof(reader));
     this.reader = reader;
     this.dictionaryReader = reader as XmlDictionaryReader;
 }
 public static object?ReadXml(this XmlDictionaryReader?xmlDictionaryReader, Type type) =>
 DataContractHelper.Deserialize(type, xmlDictionaryReader);
 public static TValue?ReadXml <TValue>(this XmlDictionaryReader?xmlDictionaryReader) =>
 DataContractHelper.Deserialize <TValue>(xmlDictionaryReader);
예제 #8
0
 /// <summary>
 /// Deserializes the XML document contained by the specified XmlReader.
 /// </summary>
 /// <param name="xmlDictionaryReader"></param>
 /// <param name="verifyObjectName"></param>
 /// <param name="dataContractResolver"></param>
 /// <typeparam name="TValue"></typeparam>
 /// <returns></returns>
 public static TValue?Deserialize <TValue>(XmlDictionaryReader?xmlDictionaryReader, bool verifyObjectName = true,
                                           DataContractResolver?dataContractResolver = null) =>
 xmlDictionaryReader is null
         ? default
         : (TValue?)Deserialize(typeof(TValue), xmlDictionaryReader, verifyObjectName, dataContractResolver);