Exemplo n.º 1
0
        void IClassifyObjectProcessor <XElement> .AfterDeserialize(XElement element)
        {
            // Some people have strange broken styles in their settings, probably added due to some bug in an earlier version of the program.
            Styles.RemoveWhere(style => style.Layers == null || style.Layers.Count == 0);
            foreach (var style in Styles)
            {
                if (style.Name == null)
                {
                    style.Name = "<unknown>";
                }
                if (style.Author == null)
                {
                    style.Author = "<unknown>";
                }
                if (style.PathTemplate == null)
                {
                    style.PathTemplate = "";
                }
            }

            // Added in v019
            if (SavedByVersion < 19 && GameInstalls != null)
            {
                GameInstallations = GameInstalls;
            }
#pragma warning disable 0618 // ActiveInstallation should only be used for loading/saving the setting, which is what the code below does.
            if (SavedByVersion < 19 && SelectedGamePath != null)
            {
                ActiveInstallation = GameInstallations.Where(gi => gi.Path.EqualsNoCase(SelectedGamePath)).FirstOrDefault() ?? GameInstallations.FirstOrDefault();
            }
#pragma warning restore 0618
            if (SavedByVersion < 19 && SelectedStyleNameAndAuthor != null)
            {
                // This is a fairly approximate match but this way at least some users will see the right style still selected. The old property was too lossy to allow for reliable matching.
                ActiveStyle = Styles.FirstOrDefault(s => SelectedStyleNameAndAuthor.Contains(s.Name) && SelectedStyleNameAndAuthor.Contains(s.Author));
            }
            GameInstalls               = null;
            SelectedGamePath           = null;
            SelectedStyleNameAndAuthor = null;
        }