本文整理汇总了C#中IAggregateRoot.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IAggregateRoot.GetType方法的具体用法?C# IAggregateRoot.GetType怎么用?C# IAggregateRoot.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAggregateRoot
的用法示例。
在下文中一共展示了IAggregateRoot.GetType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public void Handle(IAggregateRoot root, IDomainEvent ev)
{
MethodInvoker invoker;
if (!_handlers.TryGetValue(ev.GetType(), out invoker))
{
throw new InvalidOperationException(string.Format("Apply method for event [{0}] wasn't resolved in [{1}]", ev.GetType().Name, root.GetType().Name));
}
invoker.Invoke(root, new object[] {ev});
}
示例2: CreateMessage
private DomainEventStreamMessage CreateMessage(IAggregateRoot aggregateRoot)
{
return new DomainEventStreamMessage(
ObjectId.GenerateNewStringId(),
aggregateRoot.UniqueId,
aggregateRoot.Version + 1,
aggregateRoot.GetType().FullName,
aggregateRoot.GetChanges(),
new Dictionary<string, string>());
}
示例3: CreateSnapshot
public Snapshot CreateSnapshot(IAggregateRoot aggregateRoot)
{
if (aggregateRoot == null)
{
throw new ArgumentNullException("aggregateRoot");
}
var payload = _binarySerializer.Serialize(aggregateRoot);
var aggregateRootTypeCode = _aggregateRootTypeCodeProvider.GetTypeCode(aggregateRoot.GetType());
return new Snapshot(aggregateRootTypeCode, aggregateRoot.UniqueId, aggregateRoot.Version, payload, DateTime.Now);
}
示例4: TryGetFromSnapshot
private bool TryGetFromSnapshot(string aggregateRootId, Type aggregateRootType, out IAggregateRoot aggregateRoot)
{
aggregateRoot = _aggregateSnapshotter.RestoreFromSnapshot(aggregateRootType, aggregateRootId);
if (aggregateRoot == null) return false;
if (aggregateRoot.GetType() != aggregateRootType || aggregateRoot.UniqueId != aggregateRootId)
{
throw new Exception(string.Format("AggregateRoot recovery from snapshot is invalid as the aggregateRootType or aggregateRootId is not matched. Snapshot: [aggregateRootType:{0},aggregateRootId:{1}], expected: [aggregateRootType:{2},aggregateRootId:{3}]",
aggregateRoot.GetType(),
aggregateRoot.UniqueId,
aggregateRootType,
aggregateRootId));
}
var aggregateRootTypeName = _typeNameProvider.GetTypeName(aggregateRootType);
var eventStreamsAfterSnapshot = _eventStore.QueryAggregateEvents(aggregateRootId, aggregateRootTypeName, aggregateRoot.Version + 1, int.MaxValue);
aggregateRoot.ReplayEvents(eventStreamsAfterSnapshot);
return true;
}
示例5: Apply
internal static void Apply(IAggregateRoot root, IDomainEvent ev)
{
var rootType = root.GetType();
EventHandlerRegistry registry;
if (!_handlers.TryGetValue(rootType, out registry))
{
registry = new EventHandlerRegistry(ApplyMethodResolver.ResolveAll(rootType));
_handlers[rootType] = registry;
}
registry.Handle(root, ev);
//ResolveApplyMethodDelegate(root.GetType(), ev.GetType())(root, ev);
}
示例6: CreateMessage
private static string CreateMessage(IAggregateRoot aggRoot, Guid originalVersion, Guid currentVersion)
{
var aggType = aggRoot.GetType().Name;
var msg = string.Format("The {0} you were trying to save has been updated by another user, you will have to start the editing process again to retry.", aggType);
msg += Environment.NewLine;
msg += Environment.NewLine;
msg += "Aggregate ID: " + aggRoot.AggregateId.ToString();
msg += Environment.NewLine;
msg += "Original Version: " + originalVersion.ToString();
msg += Environment.NewLine;
msg += "Current Version: " + currentVersion.ToString();
return msg;
}
示例7: RegisterAdded
///<summary>
/// 将一个FisObject注册为Added
///</summary>
///<param name="entity">fisobject</param>
///<param name="repository">该FisObject类型的Repository对象</param>
public void RegisterAdded(IAggregateRoot entity, IUnitOfWorkRepository repository)
{
if (!this._added.ContainsKey(entity))
{
logger.DebugFormat(MsgRegisterAdded, entity.GetType(), entity.Key);
this._added.Add(entity, repository);
_execSeq.Add(entity);
}
}
示例8: ConcurrencyException
public ConcurrencyException(IAggregateRoot aggregate)
: base(string.Format("Two different versions of aggregate root {0} of type '{1}' was detected in one DataSession",
((IEntity) aggregate).IdObject, aggregate.GetType().Name))
{
Aggregate = aggregate;
}
示例9: ConcurrencyException
public ConcurrencyException(IAggregateRoot root, IDomainEvent conflictEvent)
: base(string.Format("Expected version of {0}({1}) to be {2} but got {3}."
, root.GetType().Name, root.Id, root.Version, conflictEvent.Version))
{
}
示例10: CreateEventStream
private EventStream CreateEventStream(IAggregateRoot aggregateRoot, ICommand command)
{
var uncommittedEvents = aggregateRoot.GetUncommittedEvents().ToList();
aggregateRoot.ClearUncommittedEvents();
var aggregateRootTypeCode = _aggregateRootTypeProvider.GetTypeCode(aggregateRoot.GetType());
foreach (var evnt in uncommittedEvents)
{
evnt.Version = aggregateRoot.Version + 1;
}
return new EventStream(
command.Id,
aggregateRoot.UniqueId,
aggregateRootTypeCode,
aggregateRoot.Version + 1,
DateTime.Now,
uncommittedEvents);
}
示例11: PublishEvents
private void PublishEvents(IAggregateRoot instance, IDomainNotification snapshotChange)
{
foreach (var evt in instance.UncommittedEvents.ToList())
{
var modelChange = NotificationExtensions.CreateNotification(instance.GetType(), evt);
this.changes.OnNext(modelChange);
}
if (snapshotChange != null)
{
this.changes.OnNext(snapshotChange);
}
}
示例12: HandleEvent
private void HandleEvent(IAggregateRoot aggregateRoot, IDomainEvent evnt)
{
var handler = _eventHandlerProvider.GetInternalEventHandler(aggregateRoot.GetType(), evnt.GetType());
if (handler == null)
{
throw new ENodeException("Could not find event handler for [{0}] of [{1}]", evnt.GetType().FullName, aggregateRoot.GetType().FullName);
}
handler(aggregateRoot, evnt);
}
示例13: IncreaseAggregateVersion
private void IncreaseAggregateVersion(IAggregateRoot aggregateRoot)
{
_increaseVersionMethodDict[aggregateRoot.GetType()](aggregateRoot);
}