Ejemplo n.º 1
0
        public void Add(FileHavingHash fileHavingHash)
        {
            if (dictionary_.Count == 0)
            {
                if (startFileHavingHash_ == null)
                {
                    startFileHavingHash_ = fileHavingHash;
                    return;
                }
                FileHavingHash startFileHavingHash = startFileHavingHash_;
                string         startHash           = startFileHavingHash.PopHashMakerAndGetHash();
                if (startHash == null)
                {
                    resultCallback_.OnDuplicated(startFileHavingHash_.Filename, fileHavingHash.Filename);
                    return;
                }
                Step nextStep = new Step(resultCallback_);
                nextStep.Add(startFileHavingHash);
                dictionary_.Add(startHash, nextStep);
            }

            string hash = fileHavingHash.PopHashMakerAndGetHash();

            if (dictionary_.ContainsKey(hash) == false)
            {
                Step nextStep = new Step(resultCallback_);
                nextStep.Add(fileHavingHash);
                dictionary_.Add(hash, nextStep);
            }
            else
            {
                dictionary_[hash].Add(fileHavingHash);
            }
        }
Ejemplo n.º 2
0
        public FileHavingHash Create(string filename)
        {
            FileHavingHash result = new FileHavingHash();

            result.Filename = filename;
            foreach (var hashMaker in hashMakers_)
            {
                result.AddHashMaker(hashMaker);
            }
            return(result);
        }