public static bool IsVerifiableHashCollection(HashCollection hashCollection)
 {
     using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             if (!IsVerifiableHash(enumerator.Current))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        private static bool AddSingleFileInHashtable(Hashtable hashtable, HashCollection hashCollection, string location)
        {
            bool flag = false;

            if (System.IO.File.Exists(location))
            {
                using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string compositString = enumerator.Current.CompositString;
                        if (!hashtable.Contains(compositString))
                        {
                            hashtable.Add(compositString, location);
                            flag = true;
                        }
                    }
                }
            }
            return(flag);
        }
        private bool PatchSingleFile(DownloadQueueItem item, Hashtable dependencyTable)
        {
            if (item._hashCollection == null)
            {
                return(false);
            }
            string location = null;

            using (HashCollection.HashEnumerator enumerator = item._hashCollection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string compositString = enumerator.Current.CompositString;
                    if (dependencyTable.Contains(compositString))
                    {
                        location = (string)dependencyTable[compositString];
                        goto Label_0062;
                    }
                }
            }
Label_0062:
            if (location == null)
            {
                return(false);
            }
            if (this._fCancelPending)
            {
                return(false);
            }
            if (!FileHashVerified(item._hashCollection, location))
            {
                Logger.AddInternalState("Hash verify failed for " + location + ", not using it for file patching.");
                return(false);
            }
            FileStream patchSourceStream = null;
            FileStream patchTargetStream = null;

            try
            {
                patchSourceStream = GetPatchSourceStream(location);
                if (patchSourceStream == null)
                {
                    return(false);
                }
                Directory.CreateDirectory(Path.GetDirectoryName(item._targetPath));
                patchTargetStream = GetPatchTargetStream(item._targetPath);
                if (patchTargetStream == null)
                {
                    return(false);
                }
                this._eventArgs._fileSourceUri   = item._sourceUri;
                this._eventArgs.FileLocalPath    = item._targetPath;
                this._eventArgs.Cookie           = null;
                this._eventArgs._fileResponseUri = null;
                this.CheckForSizeLimit((ulong)patchSourceStream.Length, true);
                this._accumulatedBytesTotal += patchSourceStream.Length;
                this.SetBytesTotal();
                this.OnModified();
                int count     = 0;
                int tickCount = Environment.TickCount;
                patchTargetStream.SetLength(patchSourceStream.Length);
                patchTargetStream.Position = 0L;
                do
                {
                    if (this._fCancelPending)
                    {
                        return(false);
                    }
                    count = patchSourceStream.Read(this._buffer, 0, this._buffer.Length);
                    if (count > 0)
                    {
                        patchTargetStream.Write(this._buffer, 0, count);
                    }
                    this._eventArgs._bytesCompleted += count;
                    this._eventArgs._progress        = (int)((this._eventArgs._bytesCompleted * 100L) / this._eventArgs._bytesTotal);
                    this.OnModifiedWithThrottle(ref tickCount);
                }while (count > 0);
            }
            finally
            {
                if (patchSourceStream != null)
                {
                    patchSourceStream.Close();
                }
                if (patchTargetStream != null)
                {
                    patchTargetStream.Close();
                }
            }
            this._eventArgs.Cookie = item._cookie;
            this._eventArgs._filesCompleted++;
            this.OnModified();
            DownloadResult result = new DownloadResult {
                ResponseUri = null
            };

            this._downloadResults.Add(result);
            Logger.AddInternalState(item._targetPath + " is patched from store.");
            return(true);
        }