コード例 #1
0
 public Task Save(Stream stream, Map map)
 {
     return(Task.Factory.StartNew(() =>
     {
         var list = new List <SerialisedObject>
         {
             _factory.Serialise(map.Root)
         };
         list.AddRange(map.Data.Select(_factory.Serialise).Where(x => x != null));
         _formatter.Serialize(stream, list);
     }));
 }
コード例 #2
0
        public void Write(Stream stream, MapFile map, string styleHint)
        {
            var list = new List <SerialisedObject>();

            list.AddRange(map.AdditionalObjects);

            var visObj = new SerialisedObject("visgroups");

            SaveVisgroups(map.Visgroups, visObj);
            list.Add(visObj);

            SaveWorld(map, list);
            SaveCameras(map, list);

            _formatter.Serialize(stream, list);
        }
コード例 #3
0
        private string CreateCopyStream(IEnumerable <IMapObject> copiedObjects)
        {
            var clip = new SerialisedObject(SerialisedName);

            foreach (var obj in copiedObjects)
            {
                var so = _factory.Serialise(obj);
                clip.Children.Add(so);
            }
            using (var ms = new MemoryStream())
            {
                _formatter.Serialize(ms, clip);
                ms.Position = 0;
                using (var sr = new StreamReader(ms))
                {
                    return(sr.ReadToEnd());
                }
            }
        }