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(); }
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(); }
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; }
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); }
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); }
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; }
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; }
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); }
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); }
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(); }
CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options) { this.ownerNode = ownerNode; this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDef.Module)); }
CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options) { this.ownerNode = ownerNode; this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDefinition.Module)); }
public EditedEvent(EventDef originalEvent, EventDefOptions eventDefOptions) { OriginalEvent = originalEvent; EventDefOptions = eventDefOptions; }
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; }
CreateEventDefCommand(TypeNode ownerNode, EventDefOptions options) { this.ownerNode = ownerNode; eventNode = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module)); }
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; }
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; }