TypeDefSettingsCommand(ModuleDef module, TypeTreeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDef); this.origParentNode = (ILSpyTreeNode)typeNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(typeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is NamespaceTreeNode) { var asmNode = (AssemblyTreeNode)this.origParentNode.Parent; if (!AssemblyTreeNode.NamespaceStringEqualsComparer.Equals(newOptions.Namespace, origOptions.Namespace)) { this.nsNodeCreator = new NamespaceTreeNodeCreator(newOptions.Namespace, asmNode); } } if (this.nameChanged || origOptions.Namespace != newOptions.Namespace) { this.typeRefInfos = RefFinder.FindTypeRefsToThisModule(module).Where(a => RefFinder.TypeEqualityComparerInstance.Equals(a, typeNode.TypeDef)).Select(a => new TypeRefInfo(a)).ToArray(); } }
CreateTypeDefCommand(IList<TypeDef> ownerList, ILSpyTreeNode ownerNode, TypeDefOptions options) { this.ownerList = ownerList; var modNode = ILSpyTreeNode.GetNode<AssemblyTreeNode>(ownerNode); Debug.Assert(modNode != null); if (modNode == null) throw new InvalidOperationException(); this.nsNodeCreator = new NamespaceTreeNodeCreator(options.Namespace, modNode); this.typeNode = new TypeTreeNode(options.CreateTypeDef(modNode.LoadedAssembly.ModuleDefinition), modNode.Parent as AssemblyTreeNode ?? modNode); }
TypeDefSettingsCommand(ModuleDef module, TypeTreeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDefinition); this.origParentNode = (ILSpyTreeNode)typeNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(typeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) throw new InvalidOperationException(); this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is NamespaceTreeNode) { var asmNode = (AssemblyTreeNode)this.origParentNode.Parent; if (AssemblyTreeNode.NamespaceStringComparer.Compare(newOptions.Namespace, origOptions.Namespace) != 0) this.nsNodeCreator = new NamespaceTreeNodeCreator(newOptions.Namespace, asmNode); } }
TypeDefSettingsCommand(ModuleDef module, TypeTreeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDefinition); this.origParentNode = (ILSpyTreeNode)typeNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(typeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) throw new InvalidOperationException(); this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is NamespaceTreeNode) { var asmNode = (AssemblyTreeNode)this.origParentNode.Parent; if (!AssemblyTreeNode.NamespaceStringEqualsComparer.Equals(newOptions.Namespace, origOptions.Namespace)) this.nsNodeCreator = new NamespaceTreeNodeCreator(newOptions.Namespace, asmNode); } if (this.nameChanged || origOptions.Namespace != newOptions.Namespace) this.typeRefInfos = RefFinder.FindTypeRefsToThisModule(module).Where(a => RefFinder.TypeEqualityComparerInstance.Equals(a, typeNode.TypeDefinition)).Select(a => new TypeRefInfo(a)).ToArray(); }
CreateTypeDefCommand(IList<TypeDef> ownerList, ILSpyTreeNode ownerNode, TypeDefOptions options) { this.ownerList = ownerList; var modNode = ILSpyTreeNode.GetNode<AssemblyTreeNode>(ownerNode); Debug.Assert(modNode != null); if (modNode == null) throw new InvalidOperationException(); this.nsNodeCreator = new NamespaceTreeNodeCreator(options.Namespace, modNode); this.typeNode = new TypeTreeNode(options.CreateTypeDef(modNode.LoadedAssembly.ModuleDefinition), modNode.Parent as AssemblyTreeNode ?? modNode); }
TypeDefSettingsCommand(ModuleDef module, TypeTreeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDefinition); this.origParentNode = (ILSpyTreeNode)typeNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(typeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) throw new InvalidOperationException(); this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is NamespaceTreeNode) { var asmNode = (AssemblyTreeNode)this.origParentNode.Parent; if (AssemblyTreeNode.NamespaceStringComparer.Compare(newOptions.Namespace, origOptions.Namespace) != 0) this.nsNodeCreator = new NamespaceTreeNodeCreator(newOptions.Namespace, asmNode); } }