public static bool TryParse(string id, out T result) { try { var instance = (T)Activator.CreateInstance(typeof(T), true); var stringTenantUrn = AggregateRootId.Parse(id, urnFormatProvider); var newId = instance.Construct(stringTenantUrn.Id, stringTenantUrn.Tenant); if (stringTenantUrn.AggregateRootName == newId.AggregateRootName) { result = newId; } else { throw new Exception("bum"); } //todo check if ar name mateches.. return(true); } catch (Exception ex) { result = null; return(false); } }
/// <summary> /// 返回此实例的哈希代码 /// </summary> public override int GetHashCode() { return(new int[] { AggregateRootTypeCode.GetHashCode(), AggregateRootId.GetHashCode() }.Aggregate((x, y) => x ^ y)); }
private TakeSnapshotCommand BuildTakeUserSnapshotCommand(string userId) { return(new TakeSnapshotCommand() { AggregateRootId = AggregateRootId.FromString(userId), EntityId = EntityId.FromString(userId), AggregateRootType = typeof(User), EntityType = typeof(User) }); }
public override int GetHashCode() { unchecked { return((AggregateRootId.GetHashCode() * 397) ^ EntityId.GetHashCode()); } }
/// <inheritdoc /> public async Task<IEnumerable<AggregateRootInstance>> FetchFor(AggregateRootId aggregateRoot) { var aggregates = await _aggregates .Aggregates .Find(_filter.Eq(_ => _.AggregateType, aggregateRoot.Id.Value)) .ToListAsync().ConfigureAwait(false); return aggregates.Select(_ => new AggregateRootInstance(aggregateRoot, _.EventSource, _.Version)); }
public CommandDescriptor(CommandId commandId, AggregateRootId aggregateRootId, TimeSpan created, string aggregateRootType, string commandType, string commandData) { CommandId = commandId; AggregateRootId = aggregateRootId; Created = created; AggregateRootType = aggregateRootType; CommandType = commandType; CommandData = commandData; }
public override string ToString() { string commitInfo = "AggregateCommit details" + Environment.NewLine + "RootId:" + AggregateRootId.ToString() + Environment.NewLine + "Revision:" + Revision + Environment.NewLine + "Events:" + string.Join(Environment.NewLine, Events.Select(e => "\t" + e.ToString())); return(commitInfo); }
private List <CommandDescriptor> CommandDescriptorsFor(AggregateRootId aggregateRootId) { if (CommandDescriptors.Keys.Any(s => s == aggregateRootId)) { return(CommandDescriptors[aggregateRootId]); } else { var commandDescriptors = new List <CommandDescriptor>(); CommandDescriptors.Add(aggregateRootId, commandDescriptors); return(commandDescriptors); } }
public DomainEventStream AppendDomainEventStream(IDomainEventStream streamToAppend) { if (streamToAppend == null) { throw new ArgumentNullException(nameof(streamToAppend)); } if (!AggregateRootId.Equals(streamToAppend.AggregateRootId)) { throw new InvalidOperationException("Cannot append domain events belonging to a different aggregate root."); } return(new DomainEventStream(AggregateRootId, this.Concat(streamToAppend))); }
public static T Parse(string id) { var instance = (T)Activator.CreateInstance(typeof(T), true); var stringTenantUrn = AggregateRootId.Parse(id, urnFormatProvider); var newId = instance.Construct(stringTenantUrn.Id, stringTenantUrn.Tenant); if (stringTenantUrn.AggregateRootName == newId.AggregateRootName) { return(newId); } else { throw new Exception("bum"); } //todo check if ar name mateches.. }
/// <summary> /// Convert a <see cref="AggregateRootId"/> to <see cref="Artifact"/>. /// </summary> /// <param name="identifier"><see cref="AggregateRootId"/> to convert from.</param> /// <returns>Converted <see cref="Artifact"/>.</returns> public static Artifact ToProtobuf(this AggregateRootId identifier) =>
public override string GetRoutingKey() => AggregateRootId?.ToString();
public HeadquarterId(AggregateRootId id) : base(id, "Headquarter", "elders") { }
public override int GetHashCode() { return(AggregateRootId.GetHashCode() + StreamVersion.GetHashCode()); }
private string AggregateRootType(AggregateRootId aggregateRootId) { return(aggregateRootId.GetType().AssemblyQualifiedName); }
public FooId(AggregateRootId id) : base(id, "Foo", id.Tenant) { }
/// <inheritdoc /> public async Task <AggregateRootWithInstances> GetFor(AggregateRootId identifier) => new(identifier, await FetchInstances(identifier).ConfigureAwait(false));
public BarId(AggregateRootId id) : base(id, "Bar", id.Tenant) { }
public string GetAggregateId() { return(AggregateRootId.ToString()); }
private string AggregateRootType(AggregateRootId aggregateRootId) { return aggregateRootId.GetType().AssemblyQualifiedName; }
public override int GetHashCode() { return(AggregateRootName.GetHashCode() + AggregateRootId.GetHashCode() + Version.GetHashCode()); }
private List<CommandDescriptor> CommandDescriptorsFor(AggregateRootId aggregateRootId) { if (CommandDescriptors.Keys.Any(s => s == aggregateRootId)) { return CommandDescriptors[aggregateRootId]; } else { var commandDescriptors = new List<CommandDescriptor>(); CommandDescriptors.Add(aggregateRootId, commandDescriptors); return commandDescriptors; } }