Example #1
0
        public virtual MemoryStream ToXml() //Zapis do XML
        {
            DataContractSerializer _oSerializer = new DataContractSerializer(typeof(T), XmlStorageTypes.GetArray());

            using var _oStream = new MemoryStream();

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

            _oSerializer.WriteObject(_oWriter, this);

            return(_oStream);
        }
Example #2
0
        public virtual bool FromXml(Stream a_oStream) //Odczyt z XML
        {
            DataContractSerializer _oSerializer = new DataContractSerializer(typeof(T), XmlStorageTypes.GetArray());

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

            return(InitializeFromObject((T)_oSerializer.ReadObject(_oReader, false)));
        }