예제 #1
-1
파일: ResourceVM.cs 프로젝트: damnya/dnSpy
        public ResourceVM(ResourceOptions options, ModuleDef ownerModule)
        {
            this.origOptions = options;
            this.ownerModule = ownerModule;

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

            Reinitialize();
        }
예제 #2
-1
파일: ResourceVM.cs 프로젝트: damnya/dnSpy
 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;
     }
 }
예제 #3
-1
파일: ResourceVM.cs 프로젝트: damnya/dnSpy
 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
-1
        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));
        }
예제 #5
-1
        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));
        }
예제 #6
-1
        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;
        }
예제 #7
-1
        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));
        }