public VersionConsistencyException(ResourceInfo resource, MutationEvent mutation, ulong aggregateVersion)
     : base($"Версия агрегата для ресурса {resource.ToFullString()} {aggregateVersion} не соответствует базовой версии для события ${mutation}")
 {
     Resource         = resource;
     Mutation         = mutation;
     AggregateVersion = aggregateVersion;
 }
Exemple #2
0
        private void ApplyMutation(MutationEvent mutation)
        {
            var version = Version;

            State   = ApplyMutation(State, mutation, ref version);
            Version = version;
        }
Exemple #3
0
 public void Mutate(MutationEvent mutation)
 {
     mutation.BaseVersion = Version;
     ApplyMutation(mutation);
     if (Guid.Empty.Equals(mutation.Id))
     {
         repo.PushEvent(Resource, mutation);
         OnMutationEventPushed?.Invoke(mutation);
     }
 }
Exemple #4
0
        private TState ApplyMutation(TState state, MutationEvent mutation, ref ulong version)
        {
            if (mutation.BaseVersion != version)
            {
                throw new VersionConsistencyException(Resource, mutation, version);
            }

            var newState = (TState)((dynamic)this).Apply(State, (dynamic)mutation);

            version++;
            return(newState);
        }