コード例 #1
0
    /// <inheritdoc />
    protected override void Setup(IServiceProvider services)
    {
        _eventStore       = services.GetRequiredService <IEventStore>();
        _executionContext = Runtime.CreateExecutionContextFor(ConfiguredTenants.First());

        var events = new List <UncommittedEvent>();

        for (var n = 0; n < EventsToCommit; n++)
        {
            events.Add(new UncommittedEvent(
                           new EventSourceId("8453f4d4-861a-4042-a4e3-c1abf1c8eadd"),
                           new Artifact(new ArtifactId(Guid.Parse("752f88c9-70f0-4ffe-82b6-a69dcc96672e")), ArtifactGeneration.First),
                           false,
                           "{ \"hello\": \"world\" }"));
        }
        _eventsToCommit = new UncommittedEvents(events);

        if (PreExistingEvents < 1)
        {
            return;
        }

        var preExistingEvents = new List <UncommittedEvent>();

        for (var n = 0; n < PreExistingEvents; n++)
        {
            preExistingEvents.Add(new UncommittedEvent(
                                      new EventSourceId("8453f4d4-861a-4042-a4e3-c1abf1c8eadd"),
                                      new Artifact(new ArtifactId(Guid.Parse("752f88c9-70f0-4ffe-82b6-a69dcc96672e")), ArtifactGeneration.First),
                                      false,
                                      "{ \"hello\": \"world\" }"));
        }

        _eventStore.Commit(new UncommittedEvents(preExistingEvents), _executionContext).GetAwaiter().GetResult();
    }
コード例 #2
0
    /// <inheritdoc />
    protected override void Setup(IServiceProvider services)
    {
        _eventStore       = services.GetRequiredService <IEventStore>();
        _executionContext = Runtime.CreateExecutionContextFor(ConfiguredTenants.First());

        _aggregateRoot = new ArtifactId(Guid.NewGuid());
        _eventSource   = new EventSourceId("fe7d58f0-2f4c-4736-8f9e-68dd7dfaec82");

        if (CommittedEvents < 1)
        {
            return;
        }

        for (var n = 0; n < CommittedEvents; n++)
        {
            _eventStore.Commit(
                new UncommittedAggregateEvents(
                    _eventSource,
                    new Artifact(_aggregateRoot, ArtifactGeneration.First),
                    (uint)n,
                    new[]
            {
                new UncommittedEvent(
                    _eventSource,
                    new Artifact(new ArtifactId(Guid.Parse("f029f857-f9e6-45d4-b3ab-4b9b0d798f2c")), ArtifactGeneration.First),
                    false,
                    "{ \"hello\": \"world\" }")
            }),
                _executionContext).GetAwaiter().GetResult();

            if (UnrelatedEventsRatio < 1)
            {
                continue;
            }

            for (var m = 0; m < UnrelatedEventsRatio; m++)
            {
                _eventStore.Commit(
                    new UncommittedEvents(new[]
                {
                    new UncommittedEvent(
                        _eventSource,
                        new Artifact(new ArtifactId(Guid.Parse("9f90d6df-0711-4ac9-bf1c-51d6090733e9")), ArtifactGeneration.First),
                        false,
                        "{ \"hello\": \"world\" }")
                }),
                    _executionContext).GetAwaiter().GetResult();
            }
        }
    }
コード例 #3
0
    /// <inheritdoc />
    protected override void Setup(IServiceProvider services)
    {
        _eventStore       = services.GetRequiredService <IEventStore>();
        _executionContext = Runtime.CreateExecutionContextFor(ConfiguredTenants.First());

        var events = new List <UncommittedEvent>();

        for (var n = 0; n < EventsToCommit; n++)
        {
            events.Add(new UncommittedEvent(
                           new EventSourceId("46c4de33-9a60-4465-97ab-a2a7f5b7e6a3"),
                           new Artifact(new ArtifactId(Guid.Parse("08db4b0a-3724-444f-9968-ada44922fb78")), ArtifactGeneration.First),
                           false,
                           "{ \"hello\": \"world\" }"));
        }

        _eventsToCommit = new UncommittedAggregateEvents(
            new EventSourceId("46c4de33-9a60-4465-97ab-a2a7f5b7e6a3"),
            new Artifact(new ArtifactId(Guid.Parse("1ad7a5dc-12e9-493a-ba10-714c88be4da7")), ArtifactGeneration.First),
            AggregateRootVersion.Initial,
            events);
    }