コード例 #1
0
ファイル: BatchSignUtil.cs プロジェクト: mmitche/roslyn-tools
        /// <summary>
        /// Build up a table of checksum to <see cref="FileName"/> instance map. This will report errors if it
        /// is unable to read any of the files off of disk.
        /// </summary>
        private ContentMap BuildContentMap(TextWriter textWriter, ref bool allGood)
        {
            var contentMap = new ContentMap();

            foreach (var fileName in _batchData.FileNames)
            {
                try
                {
                    var checksum = _contentUtil.GetChecksum(fileName.FullPath);
                    contentMap.Add(fileName, checksum);
                }
                catch (Exception ex)
                {
                    if (!File.Exists(fileName.FullPath))
                    {
                        textWriter.WriteLine($"Did not find {fileName} at {fileName.FullPath}");
                    }
                    else
                    {
                        textWriter.WriteLine($"Unable to read content of {fileName.FullPath}: {ex.Message}");
                    }
                    allGood = false;
                }
            }

            return(contentMap);
        }
コード例 #2
0
ファイル: BatchSignUtil.cs プロジェクト: tmat/roslyn-tools
        /// <summary>
        /// Build up a table of checksum to <see cref="FileName"/> instance map. This will report errors if it
        /// is unable to read any of the files off of disk.
        /// </summary>
        private ContentMap BuildContentMap(TextWriter textWriter, ref bool allGood)
        {
            var contentMap = new ContentMap();

            foreach (var fileName in _batchData.FileNames)
            {
                try
                {
                    if (string.IsNullOrEmpty(fileName.SHA256Hash))
                    {
                        var checksum = _contentUtil.GetChecksum(fileName.FullPath);
                        contentMap.Add(fileName, checksum);
                    }
                    else
                    {
                        if (File.Exists(fileName.FullPath))
                        {
                            contentMap.Add(fileName, fileName.SHA256Hash);
                        }
                        else
                        {
                            throw new FileNotFoundException();
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (!File.Exists(fileName.FullPath))
                    {
                        textWriter.WriteLine($"signtool : error : Did not find {fileName} at {fileName.FullPath}");
                    }
                    else
                    {
                        textWriter.WriteLine($"signtool : error : Unable to read content of {fileName.FullPath}: {ex.Message}");
                    }
                    allGood = false;
                }
            }

            return(contentMap);
        }