public override IEventChecker <TEntity> Check(TestableId id) { var cacheId = $"{_parent.Bucket}.{_parent.Id}.{id}"; if (!Tracked.ContainsKey(cacheId)) { throw new ExistException(typeof(TEntity), _parent.Bucket, id); } return(new EventChecker <TEntity, TState>(_uow, _ids, _factory, Tracked[cacheId])); }
public TestableId MakeId(string key) { var generated = new Guid(0, 0, 0, new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte)-_longIdCounter }); var id = new TestableId(Constants.GenerateNamedId(key), _longIdCounter--, key, generated); if (_generatedIds.ContainsKey(id.GeneratedIdKey)) { return(_generatedIds[id.GeneratedIdKey]); } return(_generatedIds[id.GeneratedIdKey] = id); }
public TestableId AnyId() { var generated = new Guid(0, 0, 0, new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte)-_longIdCounter }); var id = new TestableId(Constants.GeneratedAnyId, _longIdCounter--, generated.ToString(), generated); if (_generatedIds.ContainsKey(id.GeneratedIdKey)) { return(_generatedIds[id.GeneratedIdKey]); } return(_generatedIds[id.GeneratedIdKey] = id); }
public bool Equals(TestableId other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.LongId == LongId && other.GuidId == GuidId && other.StringId == StringId); }
public EventPlanner(TestableDomain uow, IdRegistry ids, TestableEventStore events, TestableSnapshotStore snapshots, TestableEventFactory factory, Func <TEntity> entityFactory, string bucket, TestableId id, IEntity parent = null) { _ids = ids; _uow = uow; _events = events; _snapshots = snapshots; _factory = factory; _entityFactory = entityFactory; _bucket = bucket; _id = id; _parent = parent; }
public TestableId MakeId(Id id) { if (id is TestableId) { return((TestableId)id); } // checks if the Id we get was a generated one var existing = _generatedIds.Values.FirstOrDefault(kv => kv.Equals(id)); if (existing != null) { return(existing); } var generated = new Guid(0, 0, 0, new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte)-_longIdCounter }); var testable = new TestableId(Constants.GenerateNamedId(id.ToString()), _longIdCounter--, id.ToString(), generated); if (_generatedIds.ContainsKey(testable.GeneratedIdKey)) { return(_generatedIds[testable.GeneratedIdKey]); } return(_generatedIds[testable.GeneratedIdKey] = testable); }
public override IEventPlanner <TEntity> Plan(TestableId id) { return(new EventPlanner <TEntity, TState>(_uow, _ids, _eventstore, _snapstore, _factory, () => Get(id).Result, _parent.Bucket, id, _parent)); }
public IEventPlanner <TChild> Plan <TChild>(TestableId id) where TChild : IEntity, IChildEntity <TEntity> { // Use a factory so its 'lazy' - meaning defining the parent doesn't necessarily have to come before defining child return(_uow.Plan <TChild, TEntity>(_entityFactory(), id)); }
public ModelPlanner(TestableApplication app, IdRegistry ids, Id id) { _app = app; _ids = ids; _id = _ids.MakeId(id); }
public IEventChecker <TChild> Check <TChild>(TestableId id) where TChild : IEntity, IChildEntity <TEntity> { return(_uow.Check <TChild, TEntity>(_entity, id)); }