コード例 #1
0
        public static async Task SaveAsync(string filename, KneeboardTheme theme)
        {
            theme.Filename = filename;

            var themeData = new Dictionary <string, object>();

            foreach (PropertyDescriptor prop in theme.GetProperties())
            {
                themeData.Add(prop.Name, prop.GetValue(theme));
            }

            var themeModel = new Theme {
                Values = themeData
            };

            await WriteThemeFileAsync(filename, themeModel);

            theme.Persist();
        }
コード例 #2
0
        public static async Task <KneeboardTheme> LoadAsync(string filename)
        {
            var theme = new KneeboardTheme();

            theme.Filename = filename;

            var themeData = (await ReadThemeFileAsync(filename)).Values;

            foreach (PropertyDescriptor prop in theme.GetProperties())
            {
                if (themeData.ContainsKey(prop.Name))
                {
                    prop.SetValue(theme, themeData[prop.Name]);
                }
            }

            theme.Persist();
            return(theme);
        }