Exemple #1
0
 public async Task WriteMenuCardToFileAsync(MenuCard menuCard, StorageFile storageFile)
 {
     var menuCardData = new MenuCardData(menuCard);
     var knownTypes = new Type[]
   {
     typeof(MenuItemData)
   };
     var cardStream = new MemoryStream();
     var serializer = new DataContractSerializer(typeof(MenuCardData), knownTypes);
     serializer.WriteObject(cardStream, menuCardData);
     using (Stream fileStream = await storageFile.OpenStreamForWriteAsync())
     {
         cardStream.Seek(0, SeekOrigin.Begin);
         await cardStream.CopyToAsync(fileStream);
         await fileStream.FlushAsync();
     }
 }
Exemple #2
0
        public async Task WriteMenuCardToFileAsync(MenuCard menuCard, StorageFile storageFile)
        {
            var menuCardData = new MenuCardData(menuCard);
            var knownTypes   = new Type[]
            {
                typeof(MenuItemData)
            };
            var cardStream = new MemoryStream();
            var serializer = new DataContractSerializer(typeof(MenuCardData), knownTypes);

            serializer.WriteObject(cardStream, menuCardData);
            using (Stream fileStream = await storageFile.OpenStreamForWriteAsync())
            {
                cardStream.Seek(0, SeekOrigin.Begin);
                await cardStream.CopyToAsync(fileStream);

                await fileStream.FlushAsync();
            }
        }