示例#1
0
        private static BlobOperationResult ExtractAsyncOperationInfo(Dictionary <string, object> recordDictionary)
        {
            // Note that these property keys may be present in the dictionary, but with a value of null.
            // This is why we need to do the null check, instead of if(Dictionary.TryGetValue()).
            recordDictionary.TryGetValue(Constants.ChangeFeed.EventData.AsyncOperationInfo, out object asyncOperationInfoObject);
            if (asyncOperationInfoObject == null)
            {
                return(null);
            }

            Dictionary <string, object> asyncOperationInfoDictionary = (Dictionary <string, object>)asyncOperationInfoObject;

            BlobOperationResult asyncOperationInfo = new BlobOperationResult();

            asyncOperationInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.DestinationTier, out object destinationTierObject);
            if (destinationTierObject != null)
            {
                asyncOperationInfo.DestinationAccessTier = new AccessTier((string)destinationTierObject);
            }

            asyncOperationInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.WasAsyncOperation, out object wasAsyncOperationObject);
            if (wasAsyncOperationObject != null)
            {
                asyncOperationInfo.IsAsync = bool.Parse((string)wasAsyncOperationObject);
            }

            asyncOperationInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.CopyId, out object copyIdObject);
            asyncOperationInfo.CopyId = (string)copyIdObject;

            return(asyncOperationInfo);
        }
示例#2
0
 /// <summary>
 /// Creates a new BlobChangeFeedEventData instance for mocking.
 /// </summary>
 public static BlobChangeFeedEventData BlobChangeFeedEventData(
     string blobOperationName,
     string clientRequestId,
     Guid requestId,
     ETag eTag,
     string contentType,
     long contentLength,
     BlobType blobType,
     string blobVersion,
     string containerVersion,
     AccessTier?blobAccessTier,
     long contentOffset,
     Uri destinationUri,
     Uri sourceUri,
     Uri uri,
     bool recursive,
     string sequencer,
     ChangeFeedEventPreviousInfo previousInfo,
     string snapshot,
     Dictionary <string, BlobPropertyChange> updatedBlobProperties,
     BlobOperationResult asyncOperationInfo,
     BlobTagsChange updatedBlobTags)
 => new BlobChangeFeedEventData
 {
     BlobOperationName = blobOperationName,
     ClientRequestId   = clientRequestId,
     RequestId         = requestId,
     ETag             = eTag,
     ContentType      = contentType,
     ContentLength    = contentLength,
     BlobType         = blobType,
     BlobVersion      = blobVersion,
     ContainerVersion = containerVersion,
     BlobAccessTier   = blobAccessTier,
     ContentOffset    = contentOffset,
     DestinationUri   = destinationUri,
     SourceUri        = sourceUri,
     Uri                   = uri,
     Recursive             = recursive,
     Sequencer             = sequencer,
     PreviousInfo          = previousInfo,
     Snapshot              = snapshot,
     UpdatedBlobProperties = updatedBlobProperties,
     AsyncOperationInfo    = asyncOperationInfo,
     UpdatedBlobTags       = updatedBlobTags
 };