/// <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, BlobChangeFeedEventUpdatedBlobProperty> updatedBlobProperties,
     BlobChangeFeedEventAsyncOperationInfo asyncOperationInfo,
     BlobChangeFeedEventUpdatedBlobTags 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
 };
Пример #2
0
        private static ChangeFeedEventPreviousInfo ExtractPreviousInfo(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.PreviousInfo, out object previousInfoObject);
            if (previousInfoObject == null)
            {
                return(null);
            }

            Dictionary <string, object> previousInfoDictionary = (Dictionary <string, object>)previousInfoObject;

            ChangeFeedEventPreviousInfo previousInfo = new ChangeFeedEventPreviousInfo();

            previousInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.SoftDeletedSnapshot, out object softDeletedSnapshotObject);
            previousInfo.SoftDeleteSnapshot = (string)softDeletedSnapshotObject;

            previousInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.WasBlobSoftDeleted, out object wasBlobSoftDeletedObject);
            if (wasBlobSoftDeletedObject != null)
            {
                previousInfo.WasBlobSoftDeleted = (bool)wasBlobSoftDeletedObject;
            }

            previousInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.BlobVersion, out object blobVersionObject);
            previousInfo.NewBlobVersion = (string)blobVersionObject;

            previousInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.LastVersion, out object lastVersionObject);
            previousInfo.OldBlobVersion = (string)lastVersionObject;

            previousInfoDictionary.TryGetValue(Constants.ChangeFeed.EventData.PreviousTier, out object previousTierObject);
            if (previousTierObject != null)
            {
                previousInfo.PreviousTier = new AccessTier((string)previousTierObject);
            }

            return(previousInfo);
        }