Ejemplo n.º 1
0
        public static Profile Load(string json, string name = null)
        {
            var content = JToken.Parse(json);

            if (content != null)
            {
                if (content is JArray)
                {
                    var profile = new Profile();

                    if (name == null)
                    {
                        ProfileCreateWindow dialog = new ProfileCreateWindow();
                        if (dialog.ShowDialog() == true)
                        {
                            profile.name = dialog.profileName;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        profile.name = name;
                    }

                    JArray array = content as JArray;

                    foreach (string package in array)
                    {
                        int versionHyphenIndex = package.LastIndexOf('-');

                        string fullName = package.Substring(0, versionHyphenIndex);
                        string version  = package.Substring(versionHyphenIndex + 1);

                        profile.entries.Add(new ProfileEntry(fullName, version));
                    }

                    return(profile);
                }
                else if (content is JObject)
                {
                    return(content.ToObject <Profile>());
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private void CreateProfile_Click(object sender, RoutedEventArgs e)
        {
            ProfileCreateWindow dialog = new ProfileCreateWindow();

            if (dialog.ShowDialog() == true)
            {
                Profile newProfile = new Profile();
                newProfile.name = dialog.profileName;

                AddCurrentInstalledModsToProfile(newProfile);

                newProfile.Save();
                RecreateLists();
                SetCurrentProfile(newProfile);
            }
        }