Пример #1
0
 public sealed override Type[] GetExportedTypes() => ExportedTypes.ToArray();
Пример #2
0
        public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView, ModuleDocumentNode modNode, ModuleImporter importer)
        {
            asmNode      = modNode.TreeNode.Parent?.Data as AssemblyDocumentNode;
            this.modNode = modNode;
            var dict = new Dictionary <string, List <TypeDef> >(StringComparer.Ordinal);

            foreach (var t in importer.NewNonNestedTypes)
            {
                var ns = (t.TargetType !.Namespace ?? UTF8String.Empty).String;
                if (!dict.TryGetValue(ns, out var list))
                {
                    dict[ns] = list = new List <TypeDef>();
                }
                list.Add(t.TargetType);
            }
            newTypeNodeCreators      = dict.Values.Select(a => new TypeNodeCreator(modNode, a)).ToArray();
            existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray();
            if (!importer.MergedNonNestedTypes.All(a => a.TargetType !.Module == modNode.Document.ModuleDef))
            {
                throw new InvalidOperationException();
            }
            newAssemblyDeclSecurities   = importer.NewAssemblyDeclSecurities;
            newAssemblyCustomAttributes = importer.NewAssemblyCustomAttributes;
            newModuleCustomAttributes   = importer.NewModuleCustomAttributes;
            newExportedTypes            = importer.NewExportedTypes;
            newAssemblyVersion          = importer.NewAssemblyVersion;
            if (!(newAssemblyDeclSecurities is null))
            {
                origAssemblyDeclSecurities = modNode.Document.AssemblyDef?.DeclSecurities.ToArray();
            }
            if (!(newAssemblyCustomAttributes is null))
            {
                origAssemblyCustomAttributes = modNode.Document.AssemblyDef?.CustomAttributes.ToArray();
            }
            if (!(newModuleCustomAttributes is null))
            {
                origModuleCustomAttributes = modNode.Document.ModuleDef !.CustomAttributes.ToArray();
            }
            if (!(newExportedTypes is null))
            {
                origExportedTypes = modNode.Document.ModuleDef !.ExportedTypes.ToArray();
            }
            if (!(newAssemblyVersion is null))
            {
                origAssemblyVersion = modNode.Document.AssemblyDef?.Version;
            }

            if (importer.NewResources !.Length != 0)
            {
                var module       = modNode.Document.ModuleDef !;
                var rsrcListNode = GetResourceListTreeNode(modNode);
                Debug.Assert(!(rsrcListNode is null));
                if (!(rsrcListNode is null))
                {
                    var newNodes      = new NodeAndResource[importer.NewResources.Length];
                    var treeNodeGroup = documentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup);
                    for (int i = 0; i < newNodes.Length; i++)
                    {
                        var resource = importer.NewResources[i];
                        var node     = (DocumentTreeNodeData)documentTreeView.TreeView.Create(resourceNodeFactory.Value.Create(module, resource, treeNodeGroup)).Data;
                        newNodes[i] = new NodeAndResource(node);
                    }
                    resourceNodeCreator = new ResourceNodeCreator(rsrcListNode, newNodes);
                }
            }
        }