Пример #1
0
		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);
		}
Пример #2
0
		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;
		}
Пример #3
0
 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;
 }
Пример #4
0
		public MainWindowControlState Read(ISettingsSection section) {
			HorizontalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT));
			VerticalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(VERTICALCONTENT_SECT));

			foreach (var twSect in section.SectionsWithName(TOOLWINDOWUI_SECT)) {
				var state = ToolWindowUIState.TryDeserialize(twSect);
				if (state == null)
					continue;
				switch (state.Location) {
				case AppToolWindowLocation.Left:	LeftState = state; break;
				case AppToolWindowLocation.Right:	RightState = state; break;
				case AppToolWindowLocation.Top:		TopState = state; break;
				case AppToolWindowLocation.Bottom:	BottomState = state; break;
				}
			}

			foreach (var locSect in section.SectionsWithName(LOCATION_SECT)) {
				var guid = locSect.Attribute<Guid?>(LOCATION_GUID_ATTR);
				var loc = locSect.Attribute<AppToolWindowLocation?>(LOCATION_ATTR);
				if (guid == null || loc == null)
					continue;
				if (!IsValid(loc.Value))
					continue;
				SavedLocations[guid.Value] = loc.Value;
			}

			return this;
		}
Пример #5
0
		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;
		}
Пример #6
0
		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);
		}
Пример #7
0
		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);
			}
		}
Пример #8
0
        XElement Write(ISettingsSection section, int recursionCounter)
        {
            var xmlSect = new XElement(XmlSettingsConstants.SECTION_NAME);

            if (recursionCounter >= XmlSettingsConstants.MAX_CHILD_DEPTH)
                return xmlSect;

            xmlSect.SetAttributeValue(XmlSettingsConstants.SECTION_ATTRIBUTE_NAME, XmlUtils.EscapeAttributeValue(section.Name));
            foreach (var attr in section.Attributes.OrderBy(a => a.Item1.ToUpperInvariant())) {
                var n = XmlUtils.FilterAttributeName(attr.Item1);
                Debug.Assert(n != null, "Invalid character(s) in section attribute name. Only valid XML attribute names can be used.");
                if (n == null)
                    continue;
                bool b = n == XmlSettingsConstants.SECTION_ATTRIBUTE_NAME;
                Debug.Assert(!b, string.Format("Attribute name '{0}' is reserved for use by the XML writer", XmlSettingsConstants.SECTION_ATTRIBUTE_NAME));
                if (b)
                    continue;
                xmlSect.SetAttributeValue(n, XmlUtils.EscapeAttributeValue(attr.Item2));
            }

            foreach (var childSection in Sort(section.Sections))
                xmlSect.Add(Write(childSection, recursionCounter + 1));

            return xmlSect;
        }
Пример #9
0
		public Guid? Serialize(IFileTabContent content, ISettingsSection section) {
			var dc = content as HexFileTabContent;
			if (dc == null)
				return null;

			return GUID_SerializedContent;
		}
Пример #10
0
 public SavedWindowState Write(ISettingsSection section)
 {
     section.Attribute("Bounds", Bounds);
     section.Attribute("IsFullScreen", IsFullScreen);
     section.Attribute("WindowState", WindowState);
     return this;
 }
		public Guid? Serialize(IFileTabContent content, ISettingsSection section) {
			if (content is AssemblyChildNodeTabContent) {
				// There's nothing else we need to serialize it, but if there were, use 'section'
				// to write the info needed by Deserialize() above.
				return GUID_SerializedContent;
			}
			return null;
		}
		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);
		}
Пример #13
0
 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);
 }
Пример #14
0
		public void RemoveSection(ISettingsSection section) {
			Debug.Assert(section != null);
			if (section == null)
				throw new ArgumentNullException(nameof(section));

			bool b = sections.Remove(section);
			Debug.Assert(b);
		}
Пример #15
0
		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;
		}
Пример #16
0
		public Guid? Serialize(IFileTabContent content, ISettingsSection section) {
			var dc = content as DecompileFileTabContent;
			if (dc == null)
				return null;

			section.Attribute("Language", dc.Language.UniqueGuid);
			return GUID_SerializedContent;
		}
Пример #17
0
		public IFileTabContent Deserialize(Guid guid, ISettingsSection section, IFileTabContentFactoryContext context) {
			if (guid != GUID_SerializedContent)
				return null;
			var hexNode = context.Nodes.Length != 1 ? null : context.Nodes[0] as HexNode;
			if (hexNode == null)
				return null;

			return new HexFileTabContent(hexNode);
		}
		public DocumentTabContent Deserialize(Guid guid, ISettingsSection section, DocumentTreeNodeData[] nodes) {
			var context = new DocumentTabContentFactoryContext(nodes);
			foreach (var factory in tabContentFactories) {
				var content = factory.Value.Deserialize(guid, section, context);
				if (content != null)
					return content;
			}
			return null;
		}
		public IFileTabContent Deserialize(Guid guid, ISettingsSection section, IFileTabContentFactoryContext context) {
			if (guid == GUID_SerializedContent) {
				// Serialize() doesn't add anything extra to 'section', but if it did, you'd have to
				// get that info here and return null if the serialized data wasn't found.
				var node = context.Nodes.Length == 1 ? context.Nodes[0] as AssemblyChildNode : null;
				if (node != null)
					return new AssemblyChildNodeTabContent(node);
			}
			return null;
		}
Пример #20
0
 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 Guid? Serialize(DocumentTabContent content, ISettingsSection section) {
			var nodes = content.Nodes.ToArray();
			var context = new DocumentTabContentFactoryContext(nodes);
			foreach (var factory in tabContentFactories) {
				var guid = factory.Value.Serialize(content, section);
				if (guid != null)
					return guid;
			}
			return null;
		}
Пример #22
0
		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));
		}
Пример #23
0
		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;
		}
Пример #24
0
		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);
		}
Пример #25
0
		public void RemoveSection(ISettingsSection section) {
			Debug.Assert(section != null);
			if (section == null)
				throw new ArgumentNullException(nameof(section));

			ISettingsSection other;
			bool b = sections.TryGetValue(section.Name, out other);
			Debug.Assert(b && other == section);
			if (!b || other != section)
				return;

			sections.Remove(section.Name);
		}
Пример #26
0
		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;
		}
        private void ScrollSectionIntoView(ISettingsSection section)
        {
            var itemsControl = _content.FindVisualDescendantByType<ItemsControl>();

            if (itemsControl != null)
            {
                var sectionUI = itemsControl.ItemContainerGenerator.ContainerFromItem(section) as FrameworkElement;

                if (sectionUI != null)
                {
                    sectionUI.BringIntoView();
                }
            }
        }
Пример #28
0
		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);
			}
		}
Пример #29
0
		public void Write(ISettingsSection section) {
			Debug.Assert(HorizontalContentState != null && VerticalContentState != null);
			if (HorizontalContentState != null)
				StackedContentStateSerializer.Serialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT), HorizontalContentState);
			if (VerticalContentState != null)
				StackedContentStateSerializer.Serialize(section.GetOrCreateSection(VERTICALCONTENT_SECT), VerticalContentState);
			Debug.Assert(LeftState != null && RightState != null && TopState != null && BottomState != null);
			if (LeftState != null)
				ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), LeftState);
			if (RightState != null)
				ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), RightState);
			if (TopState != null)
				ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), TopState);
			if (BottomState != null)
				ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), BottomState);
			foreach (var kv in SavedLocations) {
				var sect = section.CreateSection(LOCATION_SECT);
				sect.Attribute(LOCATION_GUID_ATTR, kv.Key);
				sect.Attribute(LOCATION_ATTR, kv.Value);
			}
		}
Пример #30
0
        string[] LoadLabels(ISettingsSection section)
        {
            var labels = section.Attribute <string>("Labels") ?? string.Empty;

            return(labels.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.Trim()).ToArray());
        }
 public abstract void Serialize(ISettingsSection section, BookmarkLocation location);
Пример #32
0
 public object CreateSerialized(ISettingsSection section)
 {
     return(null);
 }
Пример #33
0
 public static InjectionArguments FromSection(ISettingsSection section) => new InjectionArguments
Пример #34
0
 ThemeFontSettingsSerializerImpl(ISettingsService settingsService)
 {
     toThemeFontSettingsSection = new Dictionary <string, ISettingsSection>(StringComparer.Ordinal);
     toFontSettingsSection      = new Dictionary <FontSettingsKey, ISettingsSection>(EqualityComparer <FontSettingsKey> .Default);
     rootSection = settingsService.GetOrCreateSection(SETTINGS_GUID);
 }
Пример #35
0
        public void DeserializeUI(ISettingsSection tabContentUI)
        {
            double?zoom = tabContentUI.Attribute <double?>(ZOOM_ATTR);

            elementZoomer.ZoomValue = zoom ?? 1.0;
        }
Пример #36
0
 public void SerializeUI(ISettingsSection tabContentUI) =>
 tabContentUI.Attribute(ZOOM_ATTR, elementZoomer.ZoomValue);
Пример #37
0
 public object CreateSerialized(ISettingsSection section) => null;
Пример #38
0
 public void SaveSerialized(ISettingsSection section, object obj)
 {
 }
Пример #39
0
 public void Save(ISettingsSection section)
 {
     SaveCurrentFilesToList();
     fileListManager.Save(section);
 }
Пример #40
0
 public RawSettings(ISettingsSection section)
 {
     ReadSettings(section);
 }
Пример #41
0
 public void RemoveSection(ISettingsSection section)
 {
     settingsSectionCreator.RemoveSection(section);
 }
Пример #42
0
 public void RemoveSection(ISettingsSection section) => settingsSectionProvider.RemoveSection(section);
Пример #43
0
 public object CreateSerialized(ISettingsSection section) => HexBoxUIStateSerializer.Read(section, new HexBoxUIState());
Пример #44
0
 public override object DeserializeUIState(ISettingsSection section) => HexViewUIStateSerializer.Read(section, new HexViewUIState());
Пример #45
0
 public void Save(ISettingsSection section)
 {
     SaveCurrentDocumentsToList();
     documentListService.Save(section);
 }
Пример #46
0
 void Save(ISettingsSection section, in DbgCodeBreakpointCondition settings)
Пример #47
0
		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 abstract BookmarkLocation Deserialize(ISettingsSection section);