コード例 #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
ファイル: EventOptionsVM.cs プロジェクト: net10010/dnSpy
        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
ファイル: EventDefCommands.cs プロジェクト: pashav15/pashav
        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
ファイル: EventDefCommands.cs プロジェクト: pashav15/pashav
        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
ファイル: EventOptionsVM.cs プロジェクト: se7ensoft/dnSpy
        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
ファイル: EventDefCommands.cs プロジェクト: gsong2014/dnSpy
 CreateEventDefCommand(TypeTreeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     this.eventNode = new EventTreeNode(options.CreateEventDef(ownerNode.TypeDefinition.Module));
 }
コード例 #13
0
ファイル: ImportedType.cs プロジェクト: manojdjoshi/dnSpy
		public EditedEvent(EventDef originalEvent, EventDefOptions eventDefOptions) {
			OriginalEvent = originalEvent;
			EventDefOptions = eventDefOptions;
		}
コード例 #14
0
ファイル: EventOptionsVM.cs プロジェクト: se7ensoft/dnSpy
 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
ファイル: EventOptionsVM.cs プロジェクト: se7ensoft/dnSpy
 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
ファイル: EventDefCommands.cs プロジェクト: pashav15/pashav
 CreateEventDefCommand(TypeNode ownerNode, EventDefOptions options)
 {
     this.ownerNode = ownerNode;
     eventNode      = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module));
 }
コード例 #17
0
ファイル: EventDefCommands.cs プロジェクト: gsong2014/dnSpy
        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
ファイル: EventDefCommands.cs プロジェクト: manojdjoshi/dnSpy
		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
ファイル: EventDefCommands.cs プロジェクト: manojdjoshi/dnSpy
		CreateEventDefCommand(TypeNode ownerNode, EventDefOptions options) {
			this.ownerNode = ownerNode;
			eventNode = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module));
		}