/// <summary> /// Initialises a new instance of the <see cref="Kernel"/> class. /// </summary> /// <param name="deviceSettings">Platform-specific device settings</param> /// <param name="persistedApplicationStateRepository">Platform-specific repository for the application state</param> public Kernel( IDeviceSettings deviceSettings, IPersistedApplicationStateRepository persistedApplicationStateRepository) { this.deviceSettings = deviceSettings; this.persistedApplicationStateRepository = persistedApplicationStateRepository; var applicationStateFactory = new CurrentApplicationStateFactory(this.GetCurrentApplicationState); this.bootstrap = new Bootstrap(persistedApplicationStateRepository, applicationStateFactory); var vectorClock = new VectorClock(); var eventStoreState = new EventStoreState(); this.bootstrap.EventStore.State = eventStoreState; this.bootstrap.VectorClock.SetState(vectorClock); this.bootstrap.DeviceId.SetDeviceId(deviceSettings.GetDeviceId()); this.Repositories = new ReadRepositories(this.bootstrap); this.CommandBus = this.bootstrap.CommandBus; Messenger.Default.Register <LoadApplicationStateRequested>(this, x => this.LoadApplicationState(x.Location)); this.ResetReadModelState(); }
public async Task <ulong> TerminateAsync(Guid eventID, string eventName, string streamName, ulong?expectedEventNumber, EventStoreState expectedState) { var eventData = new EventData(Uuid.FromGuid(eventID), "Delete", null, null); if (expectedEventNumber.HasValue) { var revision = new StreamRevision(expectedEventNumber.Value); var writeResult = await client.AppendToStreamAsync(streamName, revision, new EventData[] { eventData }); await client.TombstoneAsync(streamName, revision); return(writeResult.NextExpectedStreamRevision); } else { StreamState state; switch (expectedState) { case EventStoreState.Any: state = StreamState.Any; break; case EventStoreState.NotExisting: state = StreamState.NoStream; break; case EventStoreState.Existing: state = StreamState.StreamExists; break; default: throw new NotImplementedException(); } var writeResult = await client.AppendToStreamAsync(streamName, state, new EventData[] { eventData }); await client.TombstoneAsync(streamName, state); return(writeResult.NextExpectedStreamRevision); } }
public ulong Terminate(Guid eventID, string eventName, string streamName, ulong?expectedEventNumber, EventStoreState expectedState) { throw new NotSupportedException($"{nameof(EventStoreDBEngine)} does not support synchronous operations"); }