コード例 #1
0
        private Stream GetVsixResource(string name)
        {
            name = Path.GetFileName(name);
            var sr   = new MemoryStream(Content);
            var file = new VsixFile(sr, DisplayName, FileAccess.Read);

            var root = file.Nodes[0];

            return(TraverseNodes(root.Nodes, name));
        }
コード例 #2
0
        public static VsixItem Read(byte[] vsixContent, string name)
        {
            using (var contentStream = new MemoryStream(vsixContent))
            {
                using (var file = new VsixFile(contentStream, name, FileAccess.Read))
                {
                    var root = file.Nodes[0];

                    var manifestNode = root.Nodes.FirstOrDefault(n => n.Name.EndsWith(".vsixmanifest"));
                    var packageNode  = manifestNode as VsixPackagePartNode;
                    try
                    {
                        return(ReadVsixV2(name, packageNode, vsixContent));
                    }
                    catch (Exception)
                    {
                        return(ReadVsixV1(packageNode, vsixContent));
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Crawls directory recursively for VSIX files. Uses the folder names as category
        /// </summary>
        private void CreateFeedEntries(List <FeedEntry> entries, string rootPath)
        {
            try
            {
                foreach (var dir in Directory.EnumerateDirectories(rootPath))
                {
                    CreateFeedEntries(entries, dir);
                }

                string category = Path.GetFileName(rootPath);
                var    files    = Directory.EnumerateFiles(rootPath, "*.vsix");
                foreach (var f in files)
                {
                    using (var file = new VsixFile(f, FileAccess.Read))
                    {
                        var root = file.Nodes[0];

                        var manifestNode = root.Nodes.FirstOrDefault(n => n.Name.EndsWith(".vsixmanifest"));
                        var part         = manifestNode as VsixPackagePartNode;

                        FeedEntry entry;
                        try
                        {
                            entry = DeserializeManifest(part, f, category);
                        }
                        catch (InvalidOperationException)
                        {
                            entry = DeserializeManifestV2(part, f, category);
                        }
                        entries.Add(entry);
                    }
                }
            }
            catch (Exception s)
            {
                Console.WriteLine(s);
            }
        }