Exemple #1
0
            public bool TryGetValue(string key, out INamespaceNode value)
            {
                var result = _parent._childNodes.TryGetValue(key, out var node);

                value = node;
                return(result);
            }
        RenameNamespaceCommand(string newName, INamespaceNode nsNode)
        {
            this.newName        = newName;
            this.origName       = nsNode.Name;
            this.nsNode         = nsNode;
            this.existingNsNode = (INamespaceNode)nsNode.TreeNode.Parent.DataChildren.FirstOrDefault(a => a is INamespaceNode && newName == ((INamespaceNode)a).Name);

            var module = nsNode.GetModule();

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }

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

            // Make sure the exact same namespace names are restored if we undo. The names are UTF8
            // strings, but not necessarily canonicalized if it's an obfuscated assembly.
            nsNode.TreeNode.EnsureChildrenLoaded();
            this.origChildren   = nsNode.TreeNode.DataChildren.Cast <ITypeNode>().ToArray();
            this.typeNamespaces = new UTF8String[nsNode.TreeNode.Children.Count];
            for (int i = 0; i < this.typeNamespaces.Length; i++)
            {
                this.typeNamespaces[i] = origChildren[i].TypeDef.Namespace;
            }

            this.typeRefInfos = GetTypeRefInfos(module, new[] { nsNode });
        }
		public NamespaceNodeCreator(string ns, IModuleFileNode modNode) {
			this.modNode = modNode;
			this.nsNode = modNode.FindNode(ns);
			if (this.nsNode == null) {
				this.nsNode = modNode.Create(ns);
				this.nsNodeCreated = true;
			}
		}
 public NamespaceNodeCreator(string ns, IModuleFileNode modNode)
 {
     this.modNode = modNode;
     this.nsNode  = modNode.FindNode(ns);
     if (this.nsNode == null)
     {
         this.nsNode        = modNode.Create(ns);
         this.nsNodeCreated = true;
     }
 }
 static void CopyTo(IReadOnlyNamespaceNode source, INamespaceNode node)
 {
     foreach (var item in source)
     {
         node[item.Key.SourceAssembly, item.Key.Type] = item.Value;
     }
     foreach (var childNode in source.ChildNodes)
     {
         CopyTo(childNode.Value, node.GetChildNamespace(childNode.Key));
     }
 }
Exemple #6
0
        ITypeNode FindNode(INamespaceNode nsNode, TypeDef type)
        {
            if (nsNode == null || type == null)
            {
                return(null);
            }

            nsNode.TreeNode.EnsureChildrenLoaded();
            foreach (var n in nsNode.TreeNode.DataChildren.OfType <ITypeNode>())
            {
                if (n.TypeDef == type)
                {
                    return(n);
                }
            }

            return(null);
        }
Exemple #7
0
        void Decompile(INamespaceNode node)
        {
            var children = GetChildren(node).OfType <ITypeNode>().Select(a => a.TypeDef).ToArray();

            language.DecompileNamespace(node.Name, children, output, decompilationContext);
        }
Exemple #8
0
 void Decompile(INamespaceNode node)
 {
     var children = GetChildren(node).OfType<ITypeNode>().Select(a => a.TypeDef).ToArray();
     language.DecompileNamespace(node.Name, children, output, decompilationContext);
 }
 public virtual void visit(INamespaceNode value)
 {
 }
		RenameNamespaceCommand(string newName, INamespaceNode nsNode) {
			this.newName = newName;
			this.origName = nsNode.Name;
			this.nsNode = nsNode;
			this.existingNsNode = (INamespaceNode)nsNode.TreeNode.Parent.DataChildren.FirstOrDefault(a => a is INamespaceNode && newName == ((INamespaceNode)a).Name);

			var module = nsNode.GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

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

			// Make sure the exact same namespace names are restored if we undo. The names are UTF8
			// strings, but not necessarily canonicalized if it's an obfuscated assembly.
			nsNode.TreeNode.EnsureChildrenLoaded();
			this.origChildren = nsNode.TreeNode.DataChildren.Cast<ITypeNode>().ToArray();
			this.typeNamespaces = new UTF8String[nsNode.TreeNode.Children.Count];
			for (int i = 0; i < this.typeNamespaces.Length; i++)
				this.typeNamespaces[i] = origChildren[i].TypeDef.Namespace;

			this.typeRefInfos = GetTypeRefInfos(module, new[] { nsNode });
		}
		DeleteNamespaceCommand(INamespaceNode[] nodes) {
			this.parents = nodes.Select(a => (IFileTreeNodeData)a.TreeNode.Parent.Data).ToArray();
			this.nodes = new DeletableNodes<INamespaceNode>(nodes);
			this.modelNodes = new DeleteModelNodes();
		}
			public void Restore(INamespaceNode[] nodes, IFileTreeNodeData[] parents) {
				Debug.Assert(infos != null);
				if (infos == null)
					throw new InvalidOperationException();
				Debug.Assert(infos.Length == nodes.Length);
				if (infos.Length != nodes.Length)
					throw new InvalidOperationException();

				for (int i = infos.Length - 1; i >= 0; i--) {
					var info = infos[i];

					for (int j = info.Types.Length - 1; j >= 0; j--)
						info.Module.Types.Insert(info.Indexes[j], info.Types[j]);
				}

				infos = null;
			}
			public void Delete(INamespaceNode[] nodes, IFileTreeNodeData[] parents) {
				Debug.Assert(parents != null && nodes.Length == parents.Length);
				Debug.Assert(infos == null);
				if (infos != null)
					throw new InvalidOperationException();

				infos = new ModuleInfo[nodes.Length];

				for (int i = 0; i < infos.Length; i++) {
					var node = nodes[i];
					var module = parents[i].GetModule();
					Debug.Assert(module != null);
					if (module == null)
						throw new InvalidOperationException();

					var info = new ModuleInfo(module, node.TreeNode.Children.Count);
					infos[i] = info;

					for (int j = 0; j < node.TreeNode.Children.Count; j++) {
						var typeNode = (ITypeNode)node.TreeNode.Children[j].Data;
						int index = module.Types.IndexOf(typeNode.TypeDef);
						Debug.Assert(index >= 0);
						if (index < 0)
							throw new InvalidOperationException();
						module.Types.RemoveAt(index);
						info.Types[j] = typeNode.TypeDef;
						info.Indexes[j] = index;
					}
				}
			}
Exemple #14
0
 public void visit(INamespaceNode value)
 {
     string s = value.GetType().Name + ".";
     prepare_string_node(value.namespace_name, s + "name");
 }
		public virtual void visit(INamespaceNode value)
		{
		}
Exemple #16
0
 public void visit(INamespaceNode value)
 {
     throw new System.NotSupportedException(value.GetType().ToString());
 }