コード例 #1
0
 public static Task SetSystemSettingsAsync(
     this EventStoreGrpcClient client,
     SystemSettings settings,
     UserCredentials userCredentials = default, CancellationToken cancellationToken = default)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     return(client.AppendToStreamAsync(SystemStreams.SettingsStream, AnyStreamRevision.Any,
                                       new[] {
         new EventData(Uuid.NewUuid(), SystemEventTypes.Settings,
                       JsonSerializer.SerializeToUtf8Bytes(settings, SystemSettingsJsonSerializerOptions))
     }, userCredentials, cancellationToken));
 }
コード例 #2
0
        public static async Task <ConditionalWriteResult> ConditionalAppendToStreamAsync(
            this EventStoreGrpcClient client,
            string streamName,
            AnyStreamRevision expectedRevision,
            IEnumerable <EventData> eventData,
            UserCredentials userCredentials     = default,
            CancellationToken cancellationToken = default)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            try {
                var result = await client.AppendToStreamAsync(streamName, expectedRevision, eventData, userCredentials,
                                                              cancellationToken);

                return(ConditionalWriteResult.FromWriteResult(result));
            } catch (StreamDeletedException) {
                return(ConditionalWriteResult.StreamDeleted);
            } catch (WrongExpectedVersionException ex) {
                return(ConditionalWriteResult.FromWrongExpectedVersion(ex));
            }
        }