示例#1
0
        public static Settings Load()
        {
            EnsureSettingsDirectoryAvailable();

            var settings = new Settings();

            try
            {
                var path = Path.Combine(PathUtil.SettingsFolderPath, Constants.SettingsFile);

                using (var sr = new StreamReader(path))
                {
                    var document = XDocument.Load(sr);
                    var root     = document.Root;

                    var general = root?.Element(XmlGeneralElement);
                    if (general != null)
                    {
                        XElementSerializer.TryRead(general, nameof(settings.LastProcess), e => settings.LastProcess = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(general, nameof(settings.StayOnTop), e => settings.StayOnTop     = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(general, nameof(settings.RunAsAdmin), e => settings.RunAsAdmin   = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(general, nameof(settings.RandomizeWindowTitle), e => settings.RandomizeWindowTitle = XElementSerializer.ToBool(e));
                    }
                    var display = root?.Element(XmlDisplayElement);
                    if (display != null)
                    {
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeAddress), e => settings.ShowNodeAddress = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeOffset), e => settings.ShowNodeOffset   = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeText), e => settings.ShowNodeText       = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.HighlightChangedValues), e => settings.HighlightChangedValues = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentFloat), e => settings.ShowCommentFloat             = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentInteger), e => settings.ShowCommentInteger         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentPointer), e => settings.ShowCommentPointer         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentRtti), e => settings.ShowCommentRtti             = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentSymbol), e => settings.ShowCommentSymbol         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentString), e => settings.ShowCommentString         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentPluginInfo), e => settings.ShowCommentPluginInfo = XElementSerializer.ToBool(e));
                    }
                    var colors = root?.Element(XmlColorsElement);
                    if (colors != null)
                    {
                        XElementSerializer.TryRead(colors, nameof(settings.BackgroundColor), e => settings.BackgroundColor = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.SelectedColor), e => settings.SelectedColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.HiddenColor), e => settings.HiddenColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.OffsetColor), e => settings.OffsetColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.AddressColor), e => settings.AddressColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.HexColor), e => settings.HexColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.TypeColor), e => settings.TypeColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.NameColor), e => settings.NameColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.ValueColor), e => settings.ValueColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.IndexColor), e => settings.IndexColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.CommentColor), e => settings.CommentColor = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.TextColor), e => settings.TextColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.VTableColor), e => settings.VTableColor   = XElementSerializer.ToColor(e));
                    }
                    var customData = root?.Element(XmlCustomDataElement);
                    if (customData != null)
                    {
                        settings.CustomData.Deserialize(customData);
                    }
                }
            }
            catch
            {
            }

            return(settings);
        }
示例#2
0
        public static Settings Load()
        {
            EnsureSettingsDirectoryAvailable();

            var settings = new Settings();

            try
            {
                var path = Path.Combine(PathUtil.SettingsFolderPath, Constants.SettingsFile);

                using (var sr = new StreamReader(path))
                {
                    var document = XDocument.Load(sr);
                    var root     = document.Root;

                    var general = root?.Element(XmlGeneralElement);
                    if (general != null)
                    {
                        XElementSerializer.TryRead(general, nameof(settings.LastProcess), e => settings.LastProcess = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(general, nameof(settings.StayOnTop), e => settings.StayOnTop     = XElementSerializer.ToBool(e));
                    }
                    var display = root?.Element(XmlDisplayElement);
                    if (display != null)
                    {
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeAddress), e => settings.ShowNodeAddress = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeOffset), e => settings.ShowNodeOffset   = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowNodeText), e => settings.ShowNodeText       = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.HighlightChangedValues), e => settings.HighlightChangedValues = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentFloat), e => settings.ShowCommentFloat             = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentInteger), e => settings.ShowCommentInteger         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentPointer), e => settings.ShowCommentPointer         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentRtti), e => settings.ShowCommentRtti             = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentSymbol), e => settings.ShowCommentSymbol         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentString), e => settings.ShowCommentString         = XElementSerializer.ToBool(e));
                        XElementSerializer.TryRead(display, nameof(settings.ShowCommentPluginInfo), e => settings.ShowCommentPluginInfo = XElementSerializer.ToBool(e));
                    }
                    var colors = root?.Element(XmlColorsElement);
                    if (colors != null)
                    {
                        XElementSerializer.TryRead(colors, nameof(settings.BackgroundColor), e => settings.BackgroundColor = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.SelectedColor), e => settings.SelectedColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.HiddenColor), e => settings.HiddenColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.OffsetColor), e => settings.OffsetColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.AddressColor), e => settings.AddressColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.HexColor), e => settings.HexColor         = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.TypeColor), e => settings.TypeColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.NameColor), e => settings.NameColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.ValueColor), e => settings.ValueColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.IndexColor), e => settings.IndexColor     = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.CommentColor), e => settings.CommentColor = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.TextColor), e => settings.TextColor       = XElementSerializer.ToColor(e));
                        XElementSerializer.TryRead(colors, nameof(settings.VTableColor), e => settings.VTableColor   = XElementSerializer.ToColor(e));
                    }
                    var typeDefinitions = root?.Element(XmlTypeDefinitionsElement);
                    if (typeDefinitions != null)
                    {
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypePadding), e => settings.TypePadding           = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeBool), e => settings.TypeBool                 = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeInt8), e => settings.TypeInt8                 = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeInt16), e => settings.TypeInt16               = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeInt32), e => settings.TypeInt32               = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeInt64), e => settings.TypeInt64               = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUInt8), e => settings.TypeUInt8               = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUInt16), e => settings.TypeUInt16             = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUInt32), e => settings.TypeUInt32             = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUInt64), e => settings.TypeUInt64             = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeFloat), e => settings.TypeFloat               = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeDouble), e => settings.TypeDouble             = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeVector2), e => settings.TypeVector2           = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeVector3), e => settings.TypeVector3           = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeVector4), e => settings.TypeVector4           = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeMatrix3x3), e => settings.TypeMatrix3x3       = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeMatrix3x4), e => settings.TypeMatrix3x4       = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeMatrix4x4), e => settings.TypeMatrix4x4       = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF8Text), e => settings.TypeUTF8Text         = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF8TextPtr), e => settings.TypeUTF8TextPtr   = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF16Text), e => settings.TypeUTF16Text       = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF16TextPtr), e => settings.TypeUTF16TextPtr = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF32Text), e => settings.TypeUTF32Text       = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeUTF32TextPtr), e => settings.TypeUTF32TextPtr = XElementSerializer.ToString(e));
                        XElementSerializer.TryRead(typeDefinitions, nameof(settings.TypeFunctionPtr), e => settings.TypeFunctionPtr   = XElementSerializer.ToString(e));
                    }
                    var customData = root?.Element(XmlCustomDataElement);
                    if (customData != null)
                    {
                        settings.CustomData.Deserialize(customData);
                    }
                }
            }
            catch
            {
            }

            return(settings);
        }