Exemplo n.º 1
0
        private IBinaryInfo BuildBinaryInfo(IList <IPackageEntry> fileInfos, IPackageEntry binaryFileInfo)
        {
            var binaryInfo = new BinaryInfo();

            binaryInfo.Name = Path.GetFileNameWithoutExtension(binaryFileInfo.FullPath);
            binaryInfo.Type = Path.GetExtension(binaryFileInfo.FullPath).Substring(1);
            binaryInfo.File = binaryFileInfo;

            using (var stream = binaryFileInfo.GetStream())
            {
                binaryInfo.Hash = binaryStoreManager.ReadBinaryHash(stream);
                stream.Seek(0, SeekOrigin.Begin);
                binaryInfo.SymbolHash = binaryStoreManager.ReadPdbHash(stream);
            }

            string symbolName     = Path.ChangeExtension(binaryFileInfo.FullPath, "pdb");
            var    symbolFileInfo = fileInfos.SingleOrDefault(s => s.FullPath == symbolName);

            if (symbolFileInfo != null)
            {
                var symbolInfo = new SymbolInfo();
                symbolInfo.Type = Path.GetExtension(symbolFileInfo.FullPath).Substring(1);
                symbolInfo.File = symbolFileInfo;

                using (var stream = symbolFileInfo.GetStream())
                    symbolInfo.Hash = symbolStoreManager.ReadHash(stream);

                symbolInfo.SourceInfos = sourceDiscover.FindSources(fileInfos, symbolInfo);
                binaryInfo.SymbolInfo  = symbolInfo;
            }

            string documentationName     = Path.ChangeExtension(binaryFileInfo.FullPath, "xml");
            var    documentationFileInfo = fileInfos.SingleOrDefault(s => s.FullPath == documentationName);

            if (documentationFileInfo != null)
            {
                var documentationInfo = new DocumentationInfo();
                documentationInfo.Type       = Path.GetExtension(documentationFileInfo.FullPath).Substring(1);
                documentationInfo.File       = documentationFileInfo;
                binaryInfo.DocumentationInfo = documentationInfo;
            }

            return(binaryInfo);
        }