示例#1
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();
        }
示例#2
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);
 }
示例#3
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);
 }
示例#4
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;
        }
示例#5
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.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()));
        }
示例#6
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();
        }
示例#7
0
 CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDefinition.Module));
 }
示例#8
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;
        }
示例#9
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);
 }
示例#10
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;
 }
示例#11
0
 CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDefinition.Module));
 }