Example #1
0
        public static Skin FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes)
        {
            var skinSerializer = new GuiJsonSerializer(contentManager, customControlTypes);

            using (var streamReader = new StreamReader(stream))
                using (var jsonReader = new JsonTextReader(streamReader))
                {
                    return(skinSerializer.Deserialize <Skin>(jsonReader));
                }
        }
Example #2
0
        public static GuiScreen FromStream(ContentManager contentManager, Stream stream)
        {
            var skinService = new GuiSkinService();
            var serializer  = new GuiJsonSerializer(contentManager)
            {
                Converters =
                {
                    new GuiSkinJsonConverter(contentManager, skinService),
                    new GuiControlJsonConverter(skinService)
                }
            };

            using (var streamReader = new StreamReader(stream))
                using (var jsonReader = new JsonTextReader(streamReader))
                {
                    var screen = serializer.Deserialize <GuiScreen>(jsonReader);
                    return(screen);
                }
        }
        public static TScreen FromStream <TScreen>(ContentManager contentManager, Stream stream, params Type[] customControlTypes)
            where TScreen : GuiScreen
        {
            var skinService = new GuiSkinService();
            var serializer  = new GuiJsonSerializer(contentManager, customControlTypes)
            {
                Converters =
                {
                    new GuiSkinJsonConverter(contentManager, skinService, customControlTypes),
                    new GuiControlJsonConverter(skinService, customControlTypes)
                }
            };

            using (var streamReader = new StreamReader(stream))
                using (var jsonReader = new JsonTextReader(streamReader))
                {
                    var screen = serializer.Deserialize <TScreen>(jsonReader);
                    return(screen);
                }
        }
Example #4
0
        private GuiScreen LoadScreen(string name)
        {
            var skinService = new GuiSkinService();
            var serializer = new GuiJsonSerializer(Content)
            {
                Converters =
                {
                    new GuiSkinJsonConverter(Content, skinService),
                    new GuiControlJsonConverter(skinService)
                }
            };

            using (var stream = TitleContainer.OpenStream(name))
            using (var streamReader = new StreamReader(stream))
            using (var jsonReader = new JsonTextReader(streamReader))
            {
                var screen = serializer.Deserialize<GuiScreen>(jsonReader);
                return screen;
            }
        }