} = (byte)NodeAlgorithmId.Node64K; // Default to node of 64K chunks. /// <nodoc /> public NodeDedupIdentifier(HashAndAlgorithm hash) : base(hash) { Contract.Requires(hash.Bytes != null); Contract.Check(((NodeAlgorithmId)hash.AlgorithmId).IsValidNode())?.Assert($"The given hash does not represent a {nameof(NodeDedupIdentifier)}: {hash.AlgorithmId}"); NodeAlgorithm = hash.AlgorithmId; }
protected DedupIdentifier(HashAndAlgorithm hashAndAlgorithm) { if (null == hashAndAlgorithm.Bytes) { throw new ArgumentNullException(nameof(hashAndAlgorithm)); } _value = hashAndAlgorithm.Bytes; }
public static DedupIdentifier Create(HashAndAlgorithm hashAndAlgorithm) { Contract.Requires(hashAndAlgorithm.Bytes != null); byte algorithmId = hashAndAlgorithm.AlgorithmId; if (algorithmId == ChunkDedupIdentifier.ChunkAlgorithmId) { return(new ChunkDedupIdentifier(hashAndAlgorithm)); } else if (((NodeAlgorithmId)algorithmId).IsValidNode()) { return(new NodeDedupIdentifier(hashAndAlgorithm)); } else { throw new NotSupportedException($"Unknown algorithm {algorithmId}"); } }
public ChunkDedupIdentifier(HashAndAlgorithm hash) : base(hash) { Contract.Requires(hash.Bytes != null); Validate(); }