Пример #1
0
        public static void SaveProfiles()
        {
            string json = JsonConvert.SerializeObject(CleanProfiles(), Formatting.Indented);

            File.WriteAllText(Filepaths.GetProfilesFilePath(), json);
            Init(true);
        }
Пример #2
0
        public static void LoadProfiles()
        {
            string         json;
            MCProfilesList profileList;

            if (File.Exists(Filepaths.GetProfilesFilePath()))
            {
                json = File.ReadAllText(Filepaths.GetProfilesFilePath());
                try { profileList = JsonConvert.DeserializeObject <MCProfilesList>(json, JsonSerializerSettings); }
                catch { profileList = new MCProfilesList(); }
            }
            else
            {
                profileList = new MCProfilesList();
            }

            if (profileList.profiles == null)
            {
                profileList.profiles = new Dictionary <string, MCProfile>();
            }

            System.Diagnostics.Debug.WriteLine("Profile count: " + profileList.profiles.Count);
            foreach (MCProfile setting in profileList.profiles.Values)
            {
                System.Diagnostics.Debug.WriteLine("\nProfile found!: ");
                System.Diagnostics.Debug.WriteLine("Name: " + setting.Name);
                System.Diagnostics.Debug.WriteLine("Path: " + setting.ProfilePath);

                if (setting.Installations == null)
                {
                    setting.Installations = new List <MCInstallation>();
                }
                System.Diagnostics.Debug.WriteLine("Installations: " + setting.Installations.Count);
            }

            ProfileList = profileList;

            if (ProfileList.profiles.Count() == 0)
            {
                ViewModels.LauncherModel.Default.SetOverlayFrame(new Pages.FirstLaunch.WelcomePage());
            }
        }