コード例 #1
0
        public static async Task <T> RehydrateState <T>(
            this IStateRehydrator <T> rehydrator, Guid streamId)
            where T : class
        {
            if (rehydrator is null)
            {
                throw new ArgumentNullException(nameof(rehydrator));
            }

            return(await rehydrator.TryRehydrateState(streamId).ConfigureAwait(continueOnCapturedContext: false) switch
            {
                T state => state,
                _ => throw new InvalidOperationException($"Could not rehydrate state with stream id '{streamId}'.")
            });
コード例 #2
0
        public async Task TakeSnapshot(Guid streamId)
        {
            // TODO: Replace with IStateRehydrator<T>.RehydrateState() method.
            T state = await _rehydrator.TryRehydrateState(streamId).ConfigureAwait(continueOnCapturedContext: false);

            if (state == default)
            {
                string message = $"Could not rehydrate state with stream id '{streamId}'.";
                throw new InvalidOperationException(message);
            }

            CloudBlockBlob blob = GetBlobReference(streamId);

            await SetContent(blob, state).ConfigureAwait(continueOnCapturedContext: false);
            await SetProperties(blob).ConfigureAwait(continueOnCapturedContext: false);
        }