public SavedWindowState Write(ISettingsSection section) { section.Attribute("Bounds", Bounds); section.Attribute("IsFullScreen", IsFullScreen); section.Attribute("WindowState", WindowState); return this; }
public static DsDocumentInfo? TryLoad(ISettingsSection section) { var name = section.Attribute<string>(DOCUMENTINFO_NAME_ATTR); var type = section.Attribute<Guid?>(DOCUMENTINFO_TYPE_ATTR) ?? DocumentConstants.DOCUMENTTYPE_FILE; if (string.IsNullOrEmpty(name)) return null; return new DsDocumentInfo(name, type); }
public SavedWindowState Read(ISettingsSection section) { Bounds = section.Attribute<Rect?>("Bounds") ?? Rect.Empty; IsFullScreen = section.Attribute<bool?>("IsFullScreen") ?? false; WindowState = section.Attribute<WindowState?>("WindowState") ?? WindowState.Normal; return this; }
public static DnSpyFileInfo? TryLoad(ISettingsSection section) { var name = section.Attribute<string>(FILEINFO_NAME_ATTR); var type = section.Attribute<Guid?>(FILEINFO_TYPE_ATTR) ?? FileConstants.FILETYPE_FILE; if (string.IsNullOrEmpty(name)) return null; return new DnSpyFileInfo(name, type); }
public void Save(ISettingsSection section) { section.Attribute(NAME_ATTR, Name); section.Attribute(INDEX_ATTR, Index); section.Attribute(ISHORIZONTAL_ATTR, IsHorizontal); if (StackedContentState != null) StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), StackedContentState); foreach (var stg in TabGroups) stg.Save(section.CreateSection(TABGROUP_SECTION)); }
public static SerializedTabGroupWindow Load(ISettingsSection section) { var name = section.Attribute<string>(NAME_ATTR) ?? MAIN_NAME; int index = section.Attribute<int?>(INDEX_ATTR) ?? -1; bool isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR) ?? false; var stackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION)); var tgw = new SerializedTabGroupWindow(name, index, isHorizontal, stackedContentState); foreach (var tgSection in section.SectionsWithName(TABGROUP_SECTION)) tgw.TabGroups.Add(SerializedTabGroup.Load(tgSection)); return tgw; }
public static void Serialize(ISettingsSection section, StackedContentState state) { section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal); foreach (var length in state.RowsCols) { var lengthSect = section.CreateSection(LENGTH_SECTION); lengthSect.Attribute(LENGTH_ATTR, length); } }
public DocumentTabContent Deserialize(Guid guid, ISettingsSection section, IDocumentTabContentFactoryContext context) { if (guid != GUID_SerializedContent) return null; var filename = section.Attribute<string>("filename"); return hexViewDocumentTabContentCreator.Value.TryCreate(filename); }
public Guid? Serialize(DocumentTabContent content, ISettingsSection section) { var dc = content as DecompileDocumentTabContent; if (dc == null) return null; section.Attribute("Language", dc.Decompiler.UniqueGuid); return GUID_SerializedContent; }
public Guid? Serialize(DocumentTabContent content, ISettingsSection section) { var hb = content as HexViewDocumentTabContent; if (hb == null) return null; section.Attribute("filename", hb.Filename); return GUID_SerializedContent; }
public DocumentTabContent Deserialize(Guid guid, ISettingsSection section, IDocumentTabContentFactoryContext context) { if (guid != GUID_SerializedContent) return null; var langGuid = section.Attribute<Guid?>("Language") ?? DecompilerConstants.LANGUAGE_CSHARP; var language = DecompilerService.FindOrDefault(langGuid); return new DecompileDocumentTabContent(this, context.Nodes, language); }
public static FileList Create(ISettingsSection section) { var fileList = new FileList(section.Attribute<string>(FILELIST_NAME_ATTR)); foreach (var fileSect in section.SectionsWithName(FILE_SECTION)) { var info = DnSpyFileInfoSerializer.TryLoad(fileSect); if (info != null) fileList.Files.Add(info.Value); } return fileList; }
public void Load(ISettingsSection section) { var listName = section.Attribute<string>(CURRENT_LIST_ATTR); var names = new HashSet<string>(StringComparer.Ordinal); foreach (var listSection in section.SectionsWithName(DOCUMENT_LIST_SECTION)) { var documentList = DocumentList.Create(listSection); if (names.Contains(documentList.Name)) continue; documentsList.Add(documentList); } hasLoaded = true; SelectList(listName); }
public static StackedContentState TryDeserialize(ISettingsSection section) { var state = new StackedContentState(); bool? b = section.Attribute<bool?>(ISHORIZONTAL_ATTR); if (b == null) return null; state.IsHorizontal = b.Value; foreach (var lengthSect in section.SectionsWithName(LENGTH_SECTION)) { var length = lengthSect.Attribute<GridLength?>(LENGTH_ATTR); if (length == null) return null; state.RowsCols.Add(length.Value); } return state; }
void ReadSection(XElement xml, ISettingsSection section, int recursionCounter) { if (recursionCounter >= XmlSettingsConstants.MAX_CHILD_DEPTH) return; foreach (var xmlAttr in xml.Attributes()) { var attrName = xmlAttr.Name.LocalName; if (attrName == XmlSettingsConstants.SECTION_ATTRIBUTE_NAME) continue; section.Attribute(attrName, XmlUtils.UnescapeAttributeValue(xmlAttr.Value)); } foreach (var xmlSect in xml.Elements(XmlSettingsConstants.SECTION_NAME)) { var name = XmlUtils.UnescapeAttributeValue((string)xmlSect.Attribute(XmlSettingsConstants.SECTION_ATTRIBUTE_NAME)); if (name == null) continue; var childSection = section.CreateSection(name); ReadSection(xmlSect, childSection, recursionCounter + 1); } }
void ReadSettings(ISettingsSection section) { Id = section.Attribute <string>(nameof(Id)); Images = FilterOutImages(DeserializeImages(section.Attribute <string>(nameof(Images))) ?? Array.Empty <string>()).ToArray(); Stretch = section.Attribute <Stretch?>(nameof(Stretch)) ?? DefaultRawSettings.DefaultStretch; StretchDirection = section.Attribute <StretchDirection?>(nameof(StretchDirection)) ?? DefaultRawSettings.DefaultStretchDirection; Opacity = section.Attribute <double?>(nameof(Opacity)) ?? DefaultRawSettings.Opacity; HorizontalOffset = section.Attribute <double?>(nameof(HorizontalOffset)) ?? DefaultRawSettings.HorizontalOffset; VerticalOffset = section.Attribute <double?>(nameof(VerticalOffset)) ?? DefaultRawSettings.VerticalOffset; LeftMarginWidthPercent = section.Attribute <double?>(nameof(LeftMarginWidthPercent)) ?? DefaultRawSettings.LeftMarginWidthPercent; RightMarginWidthPercent = section.Attribute <double?>(nameof(RightMarginWidthPercent)) ?? DefaultRawSettings.RightMarginWidthPercent; TopMarginHeightPercent = section.Attribute <double?>(nameof(TopMarginHeightPercent)) ?? DefaultRawSettings.TopMarginHeightPercent; BottomMarginHeightPercent = section.Attribute <double?>(nameof(BottomMarginHeightPercent)) ?? DefaultRawSettings.BottomMarginHeightPercent; MaxHeight = section.Attribute <double?>(nameof(MaxHeight)) ?? DefaultRawSettings.MaxHeight; MaxWidth = section.Attribute <double?>(nameof(MaxWidth)) ?? DefaultRawSettings.MaxWidth; Zoom = section.Attribute <double?>(nameof(Zoom)) ?? DefaultRawSettings.Zoom; ImagePlacement = section.Attribute <ImagePlacement?>(nameof(ImagePlacement)) ?? DefaultRawSettings.DefaultImagePlacement; IsRandom = section.Attribute <bool?>(nameof(IsRandom)) ?? DefaultRawSettings.IsRandom; IsEnabled = section.Attribute <bool?>(nameof(IsEnabled)) ?? DefaultRawSettings.IsEnabled; Interval = section.Attribute <TimeSpan?>(nameof(Interval)) ?? DefaultRawSettings.Interval; }
// Called to create a value that can be used by Deserialize(). It's read from the settings file. public object CreateSerialized(ISettingsSection section) { var value1 = section.Attribute<string>("Value1"); var value2 = section.Attribute<bool?>("Value2"); if (value1 == null || value2 == null) return null; return new MySerializedData(value1, value2.Value); }
// Saves the value returned by Serialize(). It's saved in the settings file. public void SaveSerialized(ISettingsSection section, object obj) { var d = obj as MySerializedData; if (d == null) return; section.Attribute("Value1", d.Value1); section.Attribute("Value2", d.Value2); }
public override object DeserializeUIState(ISettingsSection section) { if (isDisposed) throw new ObjectDisposedException(nameof(IDocumentViewer)); if (section == null) throw new ArgumentNullException(nameof(section)); var caretAffinity = section.Attribute<PositionAffinity?>("CaretAffinity"); var caretVirtualSpaces = section.Attribute<int?>("CaretVirtualSpaces"); var caretPosition = section.Attribute<int?>("CaretPosition"); var viewportLeft = section.Attribute<double?>("ViewportLeft"); var topLinePosition = section.Attribute<int?>("TopLinePosition"); var topLineVerticalDistance = section.Attribute<double?>("TopLineVerticalDistance"); if (caretAffinity == null || caretVirtualSpaces == null || caretPosition == null) return null; if (viewportLeft == null || topLinePosition == null || topLineVerticalDistance == null) return null; return new EditorPositionState(caretAffinity.Value, caretVirtualSpaces.Value, caretPosition.Value, viewportLeft.Value, topLinePosition.Value, topLineVerticalDistance.Value); }
string[] LoadLabels(ISettingsSection section) { var labels = section.Attribute <string>("Labels") ?? string.Empty; return(labels.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.Trim()).ToArray()); }
public static void Serialize(ISettingsSection section, ToolWindowGroupState state) { section.Attribute(INDEX_ATTR, state.Index); foreach (var content in state.Contents) ToolWindowContentState.Serialize(section.CreateSection(CONTENT_SECT), content); }
public static void Serialize(ISettingsSection section, ToolWindowUIState state) { section.Attribute(LOCATION_ATTR, state.Location); section.Attribute(INDEX_ATTR, state.Index); section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal); foreach (var content in state.Groups) ToolWindowGroupState.Serialize(section.CreateSection(GROUP_SECT), content); Debug.Assert(state.StackedContentState != null); if (state.StackedContentState != null) StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), state.StackedContentState); }
public void DeserializeUI(ISettingsSection tabContentUI) { double? scale = tabContentUI.Attribute<double?>(SCALE_ATTR); elementScaler.ScaleValue = scale ?? 1.0; }
public static void Serialize(ISettingsSection section, ToolWindowContentState state) { section.Attribute(GUID_ATTR, state.Guid); }
void Save(ISettingsSection section, DbgCodeBreakpointCondition settings) { section.Attribute("Kind", settings.Kind); section.Attribute("Condition", settings.Condition); }
void Save(ISettingsSection section, DbgCodeBreakpointHitCount settings) { section.Attribute("Kind", settings.Kind); section.Attribute("Count", settings.Count); }
public void SaveSettings(ISettingsSection section) { section.Attribute(nameof(Id), Id); section.Attribute(nameof(Images), SerializeImages(Images)); section.Attribute(nameof(Stretch), Stretch); section.Attribute(nameof(StretchDirection), StretchDirection); section.Attribute(nameof(Opacity), Opacity); section.Attribute(nameof(HorizontalOffset), HorizontalOffset); section.Attribute(nameof(VerticalOffset), VerticalOffset); section.Attribute(nameof(LeftMarginWidthPercent), LeftMarginWidthPercent); section.Attribute(nameof(RightMarginWidthPercent), RightMarginWidthPercent); section.Attribute(nameof(TopMarginHeightPercent), TopMarginHeightPercent); section.Attribute(nameof(BottomMarginHeightPercent), BottomMarginHeightPercent); section.Attribute(nameof(MaxHeight), MaxHeight); section.Attribute(nameof(MaxWidth), MaxWidth); section.Attribute(nameof(Zoom), Zoom); section.Attribute(nameof(ImagePlacement), ImagePlacement); section.Attribute(nameof(IsRandom), IsRandom); section.Attribute(nameof(IsEnabled), IsEnabled); section.Attribute(nameof(Interval), Interval); }
public void SerializeUI(ISettingsSection tabContentUI) => tabContentUI.Attribute(ZOOM_ATTR, elementZoomer.ZoomValue);
public void DeserializeUI(ISettingsSection tabContentUI) { double?zoom = tabContentUI.Attribute <double?>(ZOOM_ATTR); elementZoomer.ZoomValue = zoom ?? 1.0; }
public static HexViewUIState Write(ISettingsSection section, HexViewUIState s) { section.Attribute("ShowOffsetColumn", s.ShowOffsetColumn); section.Attribute("ShowValuesColumn", s.ShowValuesColumn); section.Attribute("ShowAsciiColumn", s.ShowAsciiColumn); section.Attribute("StartPosition", s.StartPosition); section.Attribute("EndPosition", s.EndPosition); section.Attribute("BasePosition", s.BasePosition); section.Attribute("UseRelativePositions", s.UseRelativePositions); section.Attribute("OffsetBitSize", s.OffsetBitSize); section.Attribute("HexValuesDisplayFormat", s.HexValuesDisplayFormat); section.Attribute("BytesPerLine", s.BytesPerLine); section.Attribute("ActiveColumn", s.ActiveColumn); section.Attribute("ValuesPosition", s.ValuesPosition); section.Attribute("ValuesCellPosition", s.ValuesCellPosition); section.Attribute("AsciiPosition", s.AsciiPosition); section.Attribute("ViewportLeft", s.ViewportLeft); section.Attribute("TopLinePosition", s.TopLinePosition); section.Attribute("TopLineVerticalDistance", s.TopLineVerticalDistance); section.Attribute("AnchorPoint", s.AnchorPoint); section.Attribute("ActivePoint", s.ActivePoint); return(s); }
public static HexBoxUIState Read(ISettingsSection section, HexBoxUIState s) { if (s.HexBoxState == null) { return(s); } s.BytesGroupCount = section.Attribute <int?>("BytesGroupCount"); s.BytesPerLine = section.Attribute <int?>("BytesPerLine"); s.UseHexPrefix = section.Attribute <bool?>("UseHexPrefix"); s.ShowAscii = section.Attribute <bool?>("ShowAscii"); s.LowerCaseHex = section.Attribute <bool?>("LowerCaseHex"); s.AsciiEncoding = section.Attribute <AsciiEncoding?>("AsciiEncoding"); s.HexOffsetSize = section.Attribute <int?>("HexOffsetSize") ?? 0; s.UseRelativeOffsets = section.Attribute <bool?>("UseRelativeOffsets") ?? false; s.BaseOffset = section.Attribute <ulong?>("BaseOffset") ?? 0; s.HexBoxState.TopOffset = section.Attribute <ulong?>("HexBoxState-TopOffset") ?? 0; s.HexBoxState.Column = section.Attribute <int?>("HexBoxState-Column") ?? 0; s.HexBoxState.StartOffset = section.Attribute <ulong?>("HexBoxState-StartOffset") ?? 0; s.HexBoxState.EndOffset = section.Attribute <ulong?>("HexBoxState-EndOffset") ?? 0; s.HexBoxState.CaretPosition.Offset = section.Attribute <ulong?>("HexBoxState-HexBoxPosition-Offset") ?? 0; s.HexBoxState.CaretPosition.Kind = section.Attribute <HexBoxPositionKind?>("HexBoxState-HexBoxPosition-Kind") ?? 0; s.HexBoxState.CaretPosition.KindPosition = section.Attribute <byte?>("HexBoxState-HexBoxPosition-KindPosition") ?? 0; var from = section.Attribute <ulong?>("HexBoxState-Selection-From"); var to = section.Attribute <ulong?>("HexBoxState-Selection-To"); if (from != null && to != null) { s.HexBoxState.Selection = new HexSelection((ulong)from, (ulong)to); } return(s); }
public void SerializeUI(ISettingsSection tabContentUI) { tabContentUI.Attribute(SCALE_ATTR, elementScaler.ScaleValue); }
public static void Save(ISettingsSection section, DnSpyFileInfo info) { section.Attribute(FILEINFO_NAME_ATTR, info.Name); if (info.Type != FileConstants.FILETYPE_FILE) section.Attribute(FILEINFO_TYPE_ATTR, info.Type); }
public static ToolWindowContentState TryDeserialize(ISettingsSection section) { var guid = section.Attribute<Guid?>(GUID_ATTR); if (guid == null) return null; return new ToolWindowContentState(guid.Value); }
public static HexBoxUIState Write(ISettingsSection section, HexBoxUIState s) { if (s.HexBoxState == null) { return(s); } section.Attribute("BytesGroupCount", s.BytesGroupCount); section.Attribute("BytesPerLine", s.BytesPerLine); section.Attribute("UseHexPrefix", s.UseHexPrefix); section.Attribute("ShowAscii", s.ShowAscii); section.Attribute("LowerCaseHex", s.LowerCaseHex); section.Attribute("AsciiEncoding", s.AsciiEncoding); section.Attribute("HexOffsetSize", s.HexOffsetSize); section.Attribute("UseRelativeOffsets", s.UseRelativeOffsets); section.Attribute("BaseOffset", s.BaseOffset); section.Attribute("HexBoxState-TopOffset", s.HexBoxState.TopOffset); section.Attribute("HexBoxState-Column", s.HexBoxState.Column); section.Attribute("HexBoxState-StartOffset", s.HexBoxState.StartOffset); section.Attribute("HexBoxState-EndOffset", s.HexBoxState.EndOffset); section.Attribute("HexBoxState-HexBoxPosition-Offset", s.HexBoxState.CaretPosition.Offset); section.Attribute("HexBoxState-HexBoxPosition-Kind", s.HexBoxState.CaretPosition.Kind); section.Attribute("HexBoxState-HexBoxPosition-KindPosition", s.HexBoxState.CaretPosition.KindPosition); if (s.HexBoxState.Selection != null) { section.Attribute("HexBoxState-Selection-From", s.HexBoxState.Selection.Value.From); section.Attribute("HexBoxState-Selection-To", s.HexBoxState.Selection.Value.To); } return(s); }
public static ToolWindowGroupState TryDeserialize(ISettingsSection section) { int? index = section.Attribute<int?>(INDEX_ATTR); if (index == null) return null; var state = new ToolWindowGroupState(); state.Index = index.Value; foreach (var sect in section.SectionsWithName(CONTENT_SECT)) { var content = ToolWindowContentState.TryDeserialize(sect); if (content == null) return null; state.Contents.Add(content); } return state; }
public void DeserializeUI(ISettingsSection tabContentUI) { double? zoom = tabContentUI.Attribute<double?>(ZOOM_ATTR); elementZoomer.ZoomValue = zoom ?? 1.0; }
public static ToolWindowUIState TryDeserialize(ISettingsSection section) { var location = section.Attribute<AppToolWindowLocation?>(LOCATION_ATTR); int? index = section.Attribute<int?>(INDEX_ATTR); bool? isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR); if (location == null || index == null || isHorizontal == null) return null; var state = new ToolWindowUIState(); state.Location = location.Value; state.Index = index.Value; state.IsHorizontal = isHorizontal.Value; foreach (var sect in section.SectionsWithName(GROUP_SECT)) { var content = ToolWindowGroupState.TryDeserialize(sect); if (content == null) return null; state.Groups.Add(content); } state.StackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION)); if (state.StackedContentState == null) return null; return state; }
public void SerializeUI(ISettingsSection tabContentUI) => tabContentUI.Attribute(ZOOM_ATTR, elementZoomer.ZoomValue);
public override void SerializeUIState(ISettingsSection section, object obj) { if (isDisposed) throw new ObjectDisposedException(nameof(IDocumentViewer)); if (section == null) throw new ArgumentNullException(nameof(section)); var state = obj as EditorPositionState; Debug.Assert(state != null); if (state == null) return; section.Attribute("CaretAffinity", state.CaretAffinity); section.Attribute("CaretVirtualSpaces", state.CaretVirtualSpaces); section.Attribute("CaretPosition", state.CaretPosition); section.Attribute("ViewportLeft", state.ViewportLeft); section.Attribute("TopLinePosition", state.TopLinePosition); section.Attribute("TopLineVerticalDistance", state.TopLineVerticalDistance); }
public static void Serialize(ISettingsSection section, ToolWindowContentState state) => section.Attribute(GUID_ATTR, state.Guid);