Пример #1
0
        public virtual bool FromXml(Stream a_oStream)
        {
            DataContractSerializer _oSerialzer = new DataContractSerializer(typeof(T), XmlStorageTypes.GetArray());

            using var _oReader = XmlDictionaryReader.CreateTextReader(a_oStream, new XmlDictionaryReaderQuotas());

            return(InitializeFromObject((T)_oSerialzer.ReadObject(_oReader, false)));
        }
Пример #2
0
        public virtual MemoryStream ToXml()
        {
            DataContractSerializer _oSerialzer = new DataContractSerializer(typeof(T), XmlStorageTypes.GetArray());

            using var _oStream = new MemoryStream();

            using var _oWriter = XmlDictionaryWriter.CreateTextWriter(_oStream, Encoding.UTF8);

            _oSerialzer.WriteObject(_oWriter, this);

            return(_oStream);
        }