internal EventSourcedEntityHandler(AnySupport anySupport, IEventSourcedContext context, IBehaviorResolver behaviorReflectionCache, Func <IEventSourcedEntityCreationContext, object> entityCreationFactory = null) { AnySupport = anySupport; Context = context; EntityCreationFactory = entityCreationFactory; BehaviorReflectionCache = behaviorReflectionCache; var explicitBehaviors = Option.None <object[]>(); var active = true; void Become(object[] behaviors) { // ReSharper disable once AccessToModifiedClosure if (!active) { throw new InvalidOperationException("Context is not active!"); } explicitBehaviors = Option.Some(ValidateBehaviors(behaviors).ToArray()); } var ctx = new EventSourcedEntityCreationContext(context, Become); var entity = EntityCreationFactory(ctx); active = false; CurrentBehaviors = explicitBehaviors.Match(behaviors => behaviors, () => new[] { entity }); }
public IEventSourcedEntityHandler CreateEntityHandler(IEventSourcedContext ctx) { return(new EventSourcedEntityHandler( AnySupport, ctx, BehaviorResolver, x => Factory.Invoke(x) )); }
public ShouldSupportMultiArgConstructor(IEventSourcedContext context, [EntityId] string entityId) { Assert.Equal("foo", context.EntityId); Assert.Equal("foo", entityId); }
public CreationContextArgConstructorEntity(IEventSourcedContext context) { Assert.Equal("foo", context.EntityId); }
public UnsupportedMultipleConstructorsParameterEntity(IEventSourcedContext context) { }
public MultiArgCommandHandlerEntity(IEventSourcedContext ctx) { Ctx = ctx; Eid = ctx.EntityId; }
public EventSourcedEntityCreationContext(IEventSourcedContext @delegate, Action <object[]> become) : base(@delegate) { Become = become; }