private void PopulateBlocks() { if (this._isBlockBlob) { if (!this._isAzureBlob) { bool flag = this._contentLength % (long)4194304 != (long)0; long num = (flag ? this._contentLength / (long)4194304 + (long)1 : this._contentLength / (long)4194304); this._blockList = new BlockForCopy[checked ((IntPtr)num)]; for (long i = (long)0; i < num; i += (long)1) { long num1 = (!flag || i != num - (long)1 ? (long)4194304 : this._contentLength - i * (long)4194304); BlockForCopy[] blockForCopyArray = this._blockList; IntPtr intPtr = checked ((IntPtr)i); BlockForCopy blockForCopy = new BlockForCopy(); Guid guid = Guid.NewGuid(); blockForCopy.BlockId = DbListBlobObject.ToHexString(guid.ToByteArray()); blockForCopy.Length = (int)num1; blockForCopyArray[intPtr] = blockForCopy; } } else { this.GetBlockList(); } if (this._blockList != null) { BlockForCopy[] blockForCopyArray1 = this._blockList; for (int j = 0; j < (int)blockForCopyArray1.Length; j++) { BlockForCopy blockForCopy1 = blockForCopyArray1[j]; IStringDataEventStream info = Logger <IRestProtocolHeadLogger> .Instance.Info; object[] str = new object[] { blockForCopy1.ToString() }; info.Log("Identified Blocks:{0}", str); } } } }
private void GetBlockList() { bool flag = false; try { for (int i = 0; i < this._maxNumOfRetries; i++) { try { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create((this._sourceUrl.Contains("?") ? string.Concat(this._sourceUrl, "&comp=blocklist&&blocklisttype=committed") : string.Concat(this._sourceUrl, "?comp=blocklist&&blocklisttype=committed"))); httpWebRequest.Method = "GET"; httpWebRequest.ContentLength = (long)0; httpWebRequest.Headers["x-ms-version"] = "2011-08-18"; httpWebRequest.Headers["If-Match"] = this._etag; using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse()) { if (response.StatusCode == HttpStatusCode.OK) { using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) { List <BlockForCopy> blockForCopies = new List <BlockForCopy>(); foreach (XElement xElement in XElement.Parse(streamReader.ReadToEnd()).Elements()) { foreach (XElement xElement1 in xElement.Elements("Block")) { BlockForCopy blockForCopy = new BlockForCopy() { BlockId = DbListBlobObject.ToHexString(Convert.FromBase64String(xElement1.Element("Name").Value)), Length = int.Parse(xElement1.Element("Size").Value) }; blockForCopies.Add(blockForCopy); } } this._blockList = blockForCopies.ToArray <BlockForCopy>(); } if (this._blockList == null || (int)this._blockList.Length < 1) { this._blockList = new BlockForCopy[1]; BlockForCopy[] blockForCopyArray = this._blockList; BlockForCopy hexString = new BlockForCopy(); Guid guid = Guid.NewGuid(); hexString.BlockId = DbListBlobObject.ToHexString(guid.ToByteArray()); hexString.Length = (int)this._contentLength; blockForCopyArray[0] = hexString; } } break; } } catch (Exception exception1) { Exception exception = exception1; if (i == this._maxNumOfRetries + 1) { flag = true; throw; } if (!this.IsRetryableException(exception)) { throw; } } Thread.Sleep(1000); } } catch (Exception exception2) { this.HandleExceptionAndSetStatus(exception2, flag); } }