예제 #1
0
        public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = true,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
            OtherMethodsVM     = new MethodDefsVM(ownerModule, decompilerService);

            origOptions = options;

            TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
예제 #2
0
        public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, ILanguageManager languageManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, languageManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = true,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            this.TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, languageManager);
            this.OtherMethodsVM     = new MethodDefsVM(ownerModule, languageManager);

            this.origOptions = options;

            this.TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
예제 #3
0
		public EditedEventUpdater(ModuleDocumentNode modNode, EventDef originalEvent, EventDefOptions eventDefOptions) {
			ownerNode = modNode.Context.DocumentTreeView.FindNode(originalEvent);
			if (ownerNode == null)
				throw new InvalidOperationException();
			@event = originalEvent;
			originalEventDefOptions = new EventDefOptions(originalEvent);
			newEventDefOptions = eventDefOptions;
		}
예제 #4
0
 void InitializeFrom(EventDefOptions options)
 {
     Attributes   = options.Attributes;
     Name         = options.Name;
     EventTypeSig = options.EventType.ToTypeSig();
     AddMethod    = options.AddMethod;
     InvokeMethod = options.InvokeMethod;
     RemoveMethod = options.RemoveMethod;
     OtherMethodsVM.InitializeFrom(options.OtherMethods);
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
 }
예제 #5
0
 EventDefOptions CopyTo(EventDefOptions options)
 {
     options.Attributes   = Attributes;
     options.Name         = Name;
     options.EventType    = EventTypeSig.ToTypeDefOrRef();
     options.AddMethod    = AddMethod;
     options.InvokeMethod = InvokeMethod;
     options.RemoveMethod = RemoveMethod;
     options.OtherMethods.Clear();
     options.OtherMethods.AddRange(OtherMethodsVM.Collection.Select(a => a.Method));
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     return(options);
 }
예제 #6
0
        EventDefSettingsCommand(EventTreeNode eventNode, EventDefOptions options)
        {
            this.eventNode   = eventNode;
            this.newOptions  = options;
            this.origOptions = new EventDefOptions(eventNode.EventDef);

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

            this.nameChanged = origOptions.Name != newOptions.Name;
        }
예제 #7
0
        EventDefSettingsCommand(EventNode eventNode, EventDefOptions options)
        {
            this.eventNode = eventNode;
            newOptions     = options;
            origOptions    = new EventDefOptions(eventNode.EventDef);

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

            nameChanged = origOptions.Name != newOptions.Name;
        }
예제 #8
0
        static void Execute(Lazy <IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var ownerNode = nodes[0];

            if (!(ownerNode is TypeNode))
            {
                ownerNode = (DocumentTreeNodeData)ownerNode.TreeNode.Parent.Data;
            }
            var typeNode = ownerNode as TypeNode;

            Debug.Assert(typeNode != null);
            if (typeNode == null)
            {
                throw new InvalidOperationException();
            }

            var module = typeNode.GetModule();

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }
            var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler"));

            var data = new EventOptionsVM(options, module, appService.DecompilerService, typeNode.TypeDef);
            var win  = new EventOptionsDlg();

            win.Title       = dnSpy_AsmEditor_Resources.CreateEventCommand2;
            win.DataContext = data;
            win.Owner       = appService.MainWindow;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions());

            undoCommandService.Value.Add(cmd);
            appService.DocumentTabService.FollowReference(cmd.eventNode);
        }
예제 #9
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var ownerNode = nodes[0];

            if (!(ownerNode is TypeTreeNode))
            {
                ownerNode = (ILSpyTreeNode)ownerNode.Parent;
            }
            var typeNode = ownerNode as TypeTreeNode;

            Debug.Assert(typeNode != null);
            if (typeNode == null)
            {
                throw new InvalidOperationException();
            }

            var module = ILSpyTreeNode.GetModule(typeNode);

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }
            var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler"));

            var data = new EventOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, typeNode.TypeDef);
            var win  = new EventOptionsDlg();

            win.Title       = CMD_NAME;
            win.DataContext = data;
            win.Owner       = MainWindow.Instance;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions());

            UndoCommandManager.Instance.Add(cmd);
            MainWindow.Instance.JumpToReference(cmd.eventNode);
        }
예제 #10
0
        public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                IsLocal = false,
                CanAddGenericTypeVar = true,
                CanAddGenericMethodVar = true,
                OwnerType = ownerType,
            };
            if (ownerType != null && ownerType.GenericParameters.Count == 0)
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            this.typeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
            this.otherMethodsVM = new MethodDefsVM(ownerModule, language);

            this.origOptions = options;

            this.typeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
예제 #11
0
 CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDef.Module));
 }
예제 #12
0
 CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDefinition.Module));
 }
예제 #13
0
		public EditedEvent(EventDef originalEvent, EventDefOptions eventDefOptions) {
			OriginalEvent = originalEvent;
			EventDefOptions = eventDefOptions;
		}
예제 #14
0
 EventDefOptions CopyTo(EventDefOptions options)
 {
     options.Attributes = Attributes;
     options.Name = Name;
     options.EventType = EventTypeSig.ToTypeDefOrRef();
     options.AddMethod = AddMethod;
     options.InvokeMethod = InvokeMethod;
     options.RemoveMethod = RemoveMethod;
     options.OtherMethods.Clear();
     options.OtherMethods.AddRange(OtherMethodsVM.Collection.Select(a => a.Method));
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     return options;
 }
예제 #15
0
 void InitializeFrom(EventDefOptions options)
 {
     Attributes = options.Attributes;
     Name = options.Name;
     EventTypeSig = options.EventType.ToTypeSig();
     AddMethod = options.AddMethod;
     InvokeMethod = options.InvokeMethod;
     RemoveMethod = options.RemoveMethod;
     OtherMethodsVM.InitializeFrom(options.OtherMethods);
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
 }
예제 #16
0
 CreateEventDefCommand(TypeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     eventNode      = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module));
 }
예제 #17
0
        EventDefSettingsCommand(EventTreeNode eventNode, EventDefOptions options)
        {
            this.eventNode = eventNode;
            this.newOptions = options;
            this.origOptions = new EventDefOptions(eventNode.EventDefinition);

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

            this.nameChanged = origOptions.Name != newOptions.Name;
        }
예제 #18
0
		EventDefSettingsCommand(EventNode eventNode, EventDefOptions options) {
			this.eventNode = eventNode;
			newOptions = options;
			origOptions = new EventDefOptions(eventNode.EventDef);

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

			nameChanged = origOptions.Name != newOptions.Name;
		}
예제 #19
0
		CreateEventDefCommand(TypeNode ownerNode, EventDefOptions options) {
			this.ownerNode = ownerNode;
			eventNode = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module));
		}