예제 #1
0
        public static byte[] TryGetChecksum(ResourceKey resourceKey, PdbChecksumAlgorithm checksumAlgorithm)
        {
            Code.AssertArgument(!resourceKey.IsEmpty, nameof(resourceKey), "The resource key should be non empty.");

            var algName = GetChecksumName(checksumAlgorithm);

            using (var stream = resourceKey.TryGetResourceStream())
            {
                if (stream == null)
                {
                    return(Array <byte> .Empty);
                }

                using (var hashAlgorithm = HashAlgorithm.Create(algName))
                {
                    // ReSharper disable once PossibleNullReferenceException
                    return(hashAlgorithm.ComputeHash(stream));
                }
            }
        }
예제 #2
0
        public static Stream TryGetResourceStream(this ResourceKey resourceKey)
        {
            Code.NotNull(resourceKey.Assembly, nameof(resourceKey.Assembly));

            return(resourceKey.Assembly.GetManifestResourceStream(resourceKey.ResourceName));
        }