Beispiel #1
0
        public override bool SerializeOptimizedData(object value, Stream outputStream)
        {
            StreamWriter  sw = new StreamWriter(outputStream);
            PhotostreamVm vm = (PhotostreamVm)value;

            sw.WriteLine(vm._photos.Count);
            foreach (var photo in _photos)
            {
                sw.WriteLine(photo.Identity);
                sw.WriteLine(photo.Title);
            }
            sw.Flush();
            return(true);
        }
Beispiel #2
0
        public override object DeserializeOptimizedData(object identifier, Type objectType, Stream stream)
        {
            StreamReader sr = new StreamReader(stream);

            PhotostreamVm vm = new PhotostreamVm(sr.ReadLine());

            int count = Int32.Parse(sr.ReadLine());

            List <PhotoVm> _photos = new List <PhotoVm>();

            for (int i = 0; i < count; i++)
            {
                PhotoVm photo = new PhotoVm(sr.ReadLine());
                photo.Title = sr.ReadLine();
            }

            return(vm);
        }