コード例 #1
0
        public void Serializes_FlipTile()
        {
            // Arrange
            FlipTile tile = new FlipTile()
            {
                Id = "TileID",
                SmallBackgroundImage    = new Uri("http://localhost/some/path/1"),
                WideBackgroundImage     = new Uri("http://localhost/some/path/2"),
                WideBackBackgroundImage = new Uri("http://localhost/some/path/3"),
                WideBackContent         = "Back of wide Tile size content",
                BackgroundImage         = new Uri("/some/path/4", UriKind.Relative),
                BackBackgroundImage     = new Uri("/some/path/5", UriKind.Relative),
                BackTitle   = "你好",
                BackContent = "世界",
                Count       = 100,
                Title       = "Title"
            };
            MpnsPushMessage pushMessage = new MpnsPushMessage(tile);

            // Act
            string actual = pushMessage.ToString();

            // Assert
            Assert.Equal(Templates["FlipTile"], actual);
        }
コード例 #2
0
        public void Serializes_FlipTileEmpty()
        {
            // Arrange
            FlipTile        tile        = new FlipTile();
            MpnsPushMessage pushMessage = new MpnsPushMessage(tile);

            // Act
            string actual = pushMessage.ToString();

            // Assert
            Assert.Equal(Templates["FlipTileEmpty"], actual);
        }
コード例 #3
0
 private void WriteFlipTile(JsonWriter writer, FlipTile tile)
 {
     writer
     .StartObject()
     .WriteProperty("tiletemplate", "flip")
     .WriteProperty("tileid", tile.TileId, true)
     .WriteProperty("title", tile.FrontTitle, true)
     .WriteProperty("count", tile.FrontCount, true)
     .WriteProperty("backgroundimage", tile.FrontBackgroundImage, true)
     .WriteProperty("smallbackgroundimage", tile.SmallBackgroundImage, true)
     .WriteProperty("widebackgroundimage", tile.WideBackgroundImage, true)
     .WriteProperty("backtitle", tile.BackTitle, true)
     .WriteProperty("backbackgroundimage", tile.BackBackgroundImage, true)
     .WriteProperty("backcontent", tile.BackContent, true)
     .WriteProperty("widebackbackgroundimage", tile.WideBackBackgroundImage, true)
     .WriteProperty("widebackcontent", tile.WideBackContent, true)
     .EndObject();
 }
コード例 #4
0
        public void Serialization_IsConsistent()
        {
            // Arrange
            FlipTile tile = new FlipTile
            {
                BackBackgroundImage = new Uri("http://localhost/path1"),
                BackContent         = "back content",
                BackgroundImage     = new Uri("http://localhost/path2"),
                BackTitle           = "back title",
                Count = 10,
                Id    = "id",
                SmallBackgroundImage = new Uri("http://localhost/path3"),
                Title   = "title",
                Version = "2.0",
                WideBackBackgroundImage = new Uri("http://localhost/path4"),
                WideBackContent         = "你好世界",
                WideBackgroundImage     = new Uri("http://localhost/path5"),
            };

            // Assert
            SerializationAssert.VerifySerialization(tile, "{\"smallBackgroundImage\":\"http://localhost/path3\",\"wideBackgroundImage\":\"http://localhost/path5\",\"wideBackBackgroundImage\":\"http://localhost/path4\",\"wideBackContent\":\"你好世界\",\"backgroundImage\":\"http://localhost/path2\",\"backBackgroundImage\":\"http://localhost/path1\",\"backTitle\":\"back title\",\"backContent\":\"back content\",\"id\":\"id\",\"count\":10,\"title\":\"title\"}");
        }
コード例 #5
0
        private void InitializeFlipTileXml()
        {
            FlipTemplateManager flipManager = new FlipTemplateManager();

            if (flipManager != null)
            {
                flipManager.LoadXml("Assets/Xmls/TileTemplates.xml");

                if (flipManager.TilesDb != null && flipManager.TilesDb.Tiles != null)
                {
                    int count = flipManager.TilesDb.Tiles.Count();

                    Random   rnd      = new Random();
                    int      tileId   = rnd.Next(count);
                    FlipTile template = flipManager.TilesDb.Tiles[tileId];

                    ShellTile pinnedDefault = ShellTile.ActiveTiles.First();
                    if (pinnedDefault != null)
                    {
                        FlipTileData tileData = new FlipTileData()
                        {
                            Title                   = template.Title,
                            BackTitle               = template.BackTitle,
                            BackContent             = template.BackContent,
                            WideBackContent         = template.WideBackContent,
                            Count                   = template.Count,
                            SmallBackgroundImage    = new Uri(template.SmallBackgroundImage, UriKind.Relative),
                            BackgroundImage         = new Uri(template.BackgroundImage, UriKind.Relative),
                            BackBackgroundImage     = new Uri(template.BackBackgroundImage, UriKind.Relative),
                            WideBackgroundImage     = new Uri(template.WideBackgroundImage, UriKind.Relative),
                            WideBackBackgroundImage = new Uri(template.WideBackBackgroundImage, UriKind.Relative),
                        };

                        pinnedDefault.Update(tileData);
                    }
                }
            }
        }
コード例 #6
0
 private void WriteFlipTile(JsonWriter writer, FlipTile tile)
 {
     writer
         .StartObject()
         .WriteProperty("tiletemplate", "flip")
         .WriteProperty("tileid", tile.TileId, true)
         .WriteProperty("title", tile.FrontTitle, true)
         .WriteProperty("count", tile.FrontCount, true)
         .WriteProperty("backgroundimage", tile.FrontBackgroundImage, true)
         .WriteProperty("smallbackgroundimage", tile.SmallBackgroundImage, true)
         .WriteProperty("widebackgroundimage", tile.WideBackgroundImage, true)
         .WriteProperty("backtitle", tile.BackTitle, true)
         .WriteProperty("backbackgroundimage", tile.BackBackgroundImage, true)
         .WriteProperty("backcontent", tile.BackContent, true)
         .WriteProperty("widebackbackgroundimage", tile.WideBackBackgroundImage, true)
         .WriteProperty("widebackcontent", tile.WideBackContent, true)
         .EndObject();
 }