public void Insert(T item, object data) { var command = new CreateNodeCommand(CreateNode(item), () => data); _commands.Add(command); var metadata = _metadataFactory.Create(item); foreach (var property in metadata.Properties) { if (property.IsReadOnly) { continue; } if (property.IsList) { var collection = property.GetValue <IEnumerable>(item); CreateRelationship(item, collection, property.Relationship); continue; } if (property.HasRelationship) { CreateRelationship(item, property.Relationship); } } }
public async Task Save(MessageContext messageContext, IAggregate aggregate) { var stream = new Stream(Categories.Events, aggregate.GetType(), messageContext.AggregateId); await messageStore.Store(stream, StreamVersion.Any, aggregate.Events.Select(evt => new StorableMessage( metadataFactory.Create(messageContext), evt))); }
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) { var results = new List <IInterceptor>(); var metadata = _metadataFactory.Create(type); if (!IsSetter(method)) { return(null); } var propertyName = GetPropertyName(method); AppendRelationshipTracker(results, metadata, propertyName); AppendStateTracker(results, method); return(results.ToArray()); }
public IRecordedSnapshot <TState> Create <TAggregate, TState>(TAggregate aggregate) where TAggregate : IAggregate <TState> { return(new RecordedSnapshot <TState>(aggregate.GetId(), _typeMapper.GetAggregateName <TAggregate, TState>(), aggregate.Version, aggregate.GetState(), _metadataFactory.Create <TAggregate, TState>(aggregate), DateTimeOffset.Now)); }
public IPendingEvent Create <TAggregate, TState>(TAggregate aggregate, IEvent <TState> @event) where TAggregate : IAggregate <TState> { return(new PendingEvent(Guid.NewGuid(), _typeMapper.GetEventName(@event.GetType()), aggregate.GetId(), _typeMapper.GetAggregateName <TAggregate, TState>(), @event, _metadataFactory.Create <TAggregate, TState>(aggregate))); }