本文整理汇总了C#中IIdentity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IIdentity.ToString方法的具体用法?C# IIdentity.ToString怎么用?C# IIdentity.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIdentity
的用法示例。
在下文中一共展示了IIdentity.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendToStream
public async Task AppendToStream(IIdentity id, long expectedVersion, ICollection<IEvent> events)
{
if (events.Count == 0)
{
return;
}
var name = id.ToString();
var data = this.serializer.SerializeEvent(events.ToArray());
try
{
await this.appender.Append(name, data, expectedVersion);
}
catch (AppendOnlyStoreConcurrencyException e)
{
// load server events
var server = await this.LoadEventStream(id, 0, int.MaxValue);
// throw a real problem
throw OptimisticConcurrencyException.Create(server.Version, e.ExpectedStreamVersion, id, server.Events);
}
foreach (var @event in events)
{
Logger.DebugFormat("{0} r{1} Event: {2}", id, expectedVersion, @event);
}
}
示例2: LoadEventStream
public EventStream LoadEventStream(IIdentity id)
{
var streamId = id.ToString();
var eventStream = _eventStore.GetOrAdd(streamId, new Event[0]).ToList();
return new EventStream
{
Events = eventStream,
StreamVersion = eventStream.Count
};
}
示例3: LoadEventStream
public async Task<EventStream> LoadEventStream(IIdentity id, long skip, int take)
{
var name = id.ToString();
var records = (await this.appender.ReadRecords(name, skip, take)).ToList();
var stream = new EventStream();
foreach (var tapeRecord in records)
{
stream.Events.AddRange(this.serializer.DeserializeEvent(tapeRecord.Data));
stream.Version = tapeRecord.Version;
}
return stream;
}
示例4: AppendEventsToStream
public void AppendEventsToStream(IIdentity id, long expectedVersion, ICollection<Event> events)
{
var streamId = id.ToString();
_eventStore.AddOrUpdate(streamId, events.ToList(), (s, list) => list.Concat(events).ToList());
// to make the example simple, right after we "persist" the Events to the store above
// we immediately call the projections that handle Events.
foreach (var @event in events)
{
// log.Info("{0}", @event);
// call the eventHandler so that all subscribed projections
// can "realize and react to" the Events that happend
_eventHandler.Handle(@event);
}
}
示例5: AppendEventsToStream
public void AppendEventsToStream(IIdentity id, long streamVersion, ICollection<Event> events)
{
if (events.Count == 0) return;
// functional events don't have an identity
var name = IdentityToKey(id);
try
{
_store.AppendToStore(name, MessageAttribute.Empty, streamVersion, events.Cast<object>().ToArray());
}
catch (AppendOnlyStoreConcurrencyException e)
{
// load server events
var server = LoadEventStream(id);
// throw a real problem
throw OptimisticConcurrencyException.Create(server.StreamVersion, e.ExpectedStreamVersion, id.ToString(), server.Events);
}
}
示例6: IdentityToString
string IdentityToString(IIdentity id)
{
// in this project all identities produce proper name
return id.ToString();
}