Esempio n. 1
0
        TypeDefSettingsCommand(ModuleDef module, ITypeNode typeNode, TypeDefOptions options)
        {
            this.module      = module;
            this.typeNode    = typeNode;
            this.newOptions  = options;
            this.origOptions = new TypeDefOptions(typeNode.TypeDef);

            this.origParentNode       = (IFileTreeNodeData)typeNode.TreeNode.Parent.Data;
            this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(typeNode.TreeNode);
            Debug.Assert(this.origParentChildIndex >= 0);
            if (this.origParentChildIndex < 0)
            {
                throw new InvalidOperationException();
            }

            this.nameChanged = origOptions.Name != newOptions.Name;
            if (this.origParentNode is INamespaceNode)
            {
                var modNode = (IModuleFileNode)this.origParentNode.TreeNode.Parent.Data;
                if (newOptions.Namespace != origOptions.Namespace)
                {
                    this.nsNodeCreator = new NamespaceNodeCreator(newOptions.Namespace, modNode);
                }
            }

            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();
            }
        }
Esempio n. 2
0
		CreateTypeDefCommand(IList<TypeDef> ownerList, DocumentTreeNodeData ownerNode, TypeDefOptions options) {
			this.ownerList = ownerList;
			var modNode = ownerNode.GetModuleNode();
			Debug.Assert(modNode != null);
			if (modNode == null)
				throw new InvalidOperationException();
			nsNodeCreator = new NamespaceNodeCreator(options.Namespace, modNode);
			typeNode = modNode.Context.DocumentTreeView.Create(options.CreateTypeDef(modNode.Document.ModuleDef));
		}