Example #1
0
        /// <nodoc />
        public static int GetAvgChunkSize(this HashType hashType)
        {
            if (!hashType.IsValidDedup())
            {
                throw new NotImplementedException($"{hashType.Serialize()} doesn't support chunking.");
            }
            var hit = TypeToAvgChunkSize.TryGetValue(hashType, out var avgChunkSize);

            if (!hit)
            {
                throw new NotImplementedException($"{nameof(GetAvgChunkSize)}: No average chunk size found for hash type {hashType.Serialize()}.");
            }
            return(avgChunkSize);
        }
Example #2
0
        /// <nodoc />
        public static NodeAlgorithmId GetNodeAlgorithmId(this HashType hashType)
        {
            if (!hashType.IsValidDedup())
            {
                throw new NotImplementedException($"{hashType.Serialize()} doesn't support chunking.");
            }
            var hit = TypeToAlgorithmId.TryGetValue(hashType, out var nodeAlgorithmId);

            if (!hit)
            {
                throw new NotImplementedException($"{nameof(GetNodeAlgorithmId)}: No algorithm id found for hash type {hashType.Serialize()}.");
            }
            return(nodeAlgorithmId);
        }
Example #3
0
        /// <summary>
        ///     Create a HashInfo instance from HashType.
        /// </summary>
        public static HashInfo Find(HashType hashType)
        {
            var hit = HashInfoByType.TryGetValue(hashType, out var hashInfo);

            if (!hit)
            {
                throw new NotImplementedException($"Invalid HashType passed for HashInfoLookup: {hashType.Serialize()}, hashCode: {hashType.GetHashCode()}");
            }
#pragma warning disable CS8603 // Possible null reference return.
            return(hashInfo);

#pragma warning restore CS8603 // Possible null reference return.
        }
 public void Serialize(string value, HashType hashType)
 {
     Assert.True(hashType.Serialize().Equals(value, StringComparison.OrdinalIgnoreCase));
 }