Exemplo n.º 1
0
        protected override IMetadataTokenProvider ImportCore(MemberImportingOptions options, SharpTreeNode node)
        {
            //Checks that the task hasn't been canceled
            options.CancellationToken.ThrowIfCancellationRequested();

            //Adds the field to the destination type
            ((TypeDefinition)Destination).Fields.Add(fieldClone);
            if (_createNode)
                node.AddChildAndColorAncestors(new ILEditTreeNode(fieldClone, false));

            //Returns the new field
            return fieldClone;
        }
Exemplo n.º 2
0
        protected override IMetadataTokenProvider ImportCore(MemberImportingOptions options, SharpTreeNode node)
        {
            //Checks that the task hasn't been canceled
            options.CancellationToken.ThrowIfCancellationRequested();

            //Checks if the destination is a module or a type
            if (Destination is ModuleDefinition)
            {
                //Destination
                var dest = (ModuleDefinition)Destination;
                dest.Types.Add(typeClone);

                //Finds the correct namespace
                var ns = typeClone.Namespace;
                var moduleNode = Helpers.Tree.GetModuleNode((ModuleDefinition)Destination);
                var nsNode = moduleNode.Children.EnsureLazyChildren().OfType<NamespaceTreeNode>().FirstOrDefault(x => x.Name == ns);
                if (nsNode != null)
                    nsNode.AddChildAndColorAncestors(new ILEditTreeNode(typeClone, false));
                else
                {
                    nsNode = new NamespaceTreeNode(typeClone.Namespace) { Foreground = GlobalContainer.ModifiedNodesBrush };
                    nsNode.Children.Add(new ILEditTreeNode(typeClone, false));
                    moduleNode.AddChildAndColorAncestors(nsNode);
                }
            }
            else
            {
                //Destination
                var dest = (TypeDefinition)Destination;
                dest.NestedTypes.Add(typeClone);
                node.AddChildAndColorAncestors(new ILEditTreeNode(typeClone, false));
            }

            //Return
            return typeClone;
        }