Beispiel #1
0
        } = (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;
        }
Beispiel #2
0
        protected DedupIdentifier(HashAndAlgorithm hashAndAlgorithm)
        {
            if (null == hashAndAlgorithm.Bytes)
            {
                throw new ArgumentNullException(nameof(hashAndAlgorithm));
            }

            _value = hashAndAlgorithm.Bytes;
        }
Beispiel #3
0
        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}");
            }
        }
Beispiel #4
0
 public ChunkDedupIdentifier(HashAndAlgorithm hash)
     : base(hash)
 {
     Contract.Requires(hash.Bytes != null);
     Validate();
 }