Пример #1
0
        public ResourceVM(ResourceOptions options, ModuleDef ownerModule)
        {
            this.origOptions = options;
            this.ownerModule = ownerModule;

            this.fileHashValue = new HexStringVM(a => HasErrorUpdated());

            Reinitialize();
        }
Пример #2
0
        public ResourceVM(ResourceOptions options, ModuleDef ownerModule)
        {
            this.origOptions = options;
            this.ownerModule = ownerModule;

            this.fileHashValue = new HexStringVM(a => HasErrorUpdated());

            Reinitialize();
        }
Пример #3
0
 ResourceOptions CopyTo(ResourceOptions options)
 {
     options.ResourceType = this.Type;
     options.Attributes   = this.Attributes;
     options.Name         = this.Name;
     options.Assembly     = this.Assembly;
     options.File         = new FileDefUser(this.FileName,
                                            this.FileContainsNoMetaData ? FileAttributes.ContainsNoMetaData : FileAttributes.ContainsMetaData,
                                            this.FileHashValue.Value.ToArray());
     return(options);
 }
Пример #4
0
 void InitializeFrom(ResourceOptions options)
 {
     this.Type = options.ResourceType;
     this.ResourceVisibilityVM.SelectedItem = (ResourceVisibility)((int)(options.Attributes & ManifestResourceAttributes.VisibilityMask) >> 0);
     this.Attributes = options.Attributes;
     this.Name       = options.Name;
     this.Assembly   = options.Assembly;
     if (options.File != null)
     {
         this.FileHashValue.Value    = options.File.HashValue;
         this.FileName               = options.File.Name ?? UTF8String.Empty;
         this.FileContainsNoMetaData = options.File.ContainsNoMetaData;
     }
     else
     {
         this.FileHashValue.Value    = new byte[0];
         this.FileName               = string.Empty;
         this.FileContainsNoMetaData = false;
     }
 }
Пример #5
0
		ResourceOptions CopyTo(ResourceOptions options) {
			options.ResourceType = this.Type;
			options.Attributes = this.Attributes;
			options.Name = this.Name;
			options.Assembly = this.Assembly;
			options.File = new FileDefUser(this.FileName,
					this.FileContainsNoMetaData ? FileAttributes.ContainsNoMetaData : FileAttributes.ContainsMetaData,
					this.FileHashValue.Value.ToArray());
			return options;
		}
Пример #6
0
		void InitializeFrom(ResourceOptions options) {
			this.Type = options.ResourceType;
			this.ResourceVisibilityVM.SelectedItem = (ResourceVisibility)((int)(options.Attributes & ManifestResourceAttributes.VisibilityMask) >> 0);
			this.Attributes = options.Attributes;
			this.Name = options.Name;
			this.Assembly = options.Assembly;
			if (options.File != null) {
				this.FileHashValue.Value = options.File.HashValue;
				this.FileName = options.File.Name ?? UTF8String.Empty;
				this.FileContainsNoMetaData = options.File.ContainsNoMetaData;
			}
			else {
				this.FileHashValue.Value = new byte[0];
				this.FileName = string.Empty;
				this.FileContainsNoMetaData = false;
			}
		}
Пример #7
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.Embedded,
                Name = "my.resources",
                Attributes = ManifestResourceAttributes.Public,
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var node = new ResourceElementSetTreeNode(module, data.Name, data.Attributes);
            UndoCommandManager.Instance.Add(new CreateMultiFileResourceCommand(rsrcListNode, node));
        }
Пример #8
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.Linked,
                Name = "filelinked",
                Attributes = ManifestResourceAttributes.Public,
                File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetaData, new byte[0]),
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var opts = data.CreateResourceOptions();
            var node = ResourceFactory.Create(module, new LinkedResource(opts.Name, opts.File, opts.Attributes));
            UndoCommandManager.Instance.Add(new CreateFileLinkedResourceCommand(rsrcListNode, node));
        }
Пример #9
0
        ResourceSettingsCommand(ResourceTreeNode rsrcNode, ResourceOptions options)
        {
            this.rsrcNode = rsrcNode;
            this.newOptions = options;
            this.origOptions = new ResourceOptions(rsrcNode.Resource);

            this.origParentNode = (ILSpyTreeNode)rsrcNode.Parent;
            this.origParentChildIndex = this.origParentNode.Children.IndexOf(rsrcNode);
            Debug.Assert(this.origParentChildIndex >= 0);
            if (this.origParentChildIndex < 0)
                throw new InvalidOperationException();

            this.nameChanged = origOptions.Name != newOptions.Name;
        }
Пример #10
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.AssemblyLinked,
                Name = "asmlinked",
                Attributes = ManifestResourceAttributes.Public,
                Assembly = module.CorLibTypes.AssemblyRef,
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var node = ResourceFactory.Create(module, new AssemblyLinkedResource(data.Name, data.Assembly, data.Attributes));
            UndoCommandManager.Instance.Add(new CreateAssemblyLinkedResourceCommand(rsrcListNode, node));
        }
Пример #11
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IResourceNodeFactory resourceNodeFactory, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.Embedded,
				Name = "my.resources",
				Attributes = ManifestResourceAttributes.Public,
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateMultiFileResourceCommand2;
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var outStream = new MemoryStream();
			ResourceWriter.Write(module, outStream, new ResourceElementSet());
			var er = new EmbeddedResource(data.Name, outStream.ToArray(), data.Attributes);
			var treeView = appWindow.FileTreeView.TreeView;
			var treeNodeGroup = appWindow.FileTreeView.FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (IResourceNode)treeView.Create(resourceNodeFactory.Create(module, er, treeNodeGroup)).Data;

			undoCommandManager.Value.Add(new CreateMultiFileResourceCommand(rsrcListNode, node));
			appWindow.FileTabManager.FollowReference(node);
		}
Пример #12
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IResourceNodeFactory resourceNodeFactory, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.Linked,
				Name = "filelinked",
				Attributes = ManifestResourceAttributes.Public,
				File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetaData, new byte[0]),
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateFileLinkedResourceCommand2;
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var opts = data.CreateResourceOptions();
			var treeView = appWindow.FileTreeView.TreeView;
			var treeNodeGroup = appWindow.FileTreeView.FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (IResourceNode)treeView.Create(resourceNodeFactory.Create(module, new LinkedResource(opts.Name, opts.File, opts.Attributes), treeNodeGroup)).Data;
			undoCommandManager.Value.Add(new CreateFileLinkedResourceCommand(rsrcListNode, node));
			appWindow.FileTabManager.FollowReference(node);
		}
Пример #13
0
		static void Execute(Lazy<IUndoCommandService> undoCommandService, IAppService appService, IResourceNodeFactory resourceNodeFactory, DocumentTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.AssemblyLinked,
				Name = "asmlinked",
				Attributes = ManifestResourceAttributes.Public,
				Assembly = module.CorLibTypes.AssemblyRef,
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateAssemblyLinkedResourceCommand2;
			win.DataContext = data;
			win.Owner = appService.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var treeView = appService.DocumentTreeView.TreeView;
			var treeNodeGroup = appService.DocumentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (ResourceNode)treeView.Create(resourceNodeFactory.Create(module, new AssemblyLinkedResource(data.Name, data.Assembly, data.Attributes), treeNodeGroup)).Data;
			undoCommandService.Value.Add(new CreateAssemblyLinkedResourceCommand(rsrcListNode, node));
			appService.DocumentTabService.FollowReference(node);
		}
Пример #14
0
		ResourceSettingsCommand(ResourceNode rsrcNode, ResourceOptions options) {
			this.rsrcNode = rsrcNode;
			newOptions = options;
			origOptions = new ResourceOptions(rsrcNode.Resource);

			origParentNode = (DocumentTreeNodeData)rsrcNode.TreeNode.Parent.Data;
			origParentChildIndex = origParentNode.TreeNode.Children.IndexOf(rsrcNode.TreeNode);
			Debug.Assert(origParentChildIndex >= 0);
			if (origParentChildIndex < 0)
				throw new InvalidOperationException();

			nameChanged = origOptions.Name != newOptions.Name;
		}