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(); }
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.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; }
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.TypeDefinition); var win = new EventOptionsDlg(); win.Title = "Create Event"; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) { return; } UndoCommandManager.Instance.Add(new CreateEventDefCommand(typeNode, data.CreateEventDefOptions())); }
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.TypeDefinition.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; }
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; }