当前位置: 首页>>代码示例>>C#>>正文


C# IAggregateRoot.GetType方法代码示例

本文整理汇总了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});
		}
开发者ID:Kostassoid,项目名称:Nerve.EventStore,代码行数:10,代码来源:EventHandlerRegistry.cs

示例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>());
 }
开发者ID:ulswww,项目名称:enode,代码行数:10,代码来源:EventSequenceTest.cs

示例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);
        }
开发者ID:homerCourage,项目名称:enode,代码行数:12,代码来源:DefaultSnapshotter.cs

示例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;
        }
开发者ID:linkai0924,项目名称:enode,代码行数:21,代码来源:EventSourcingAggregateStorage.cs

示例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);
		}
开发者ID:Kostassoid,项目名称:Nerve.EventStore,代码行数:14,代码来源:DomainSettings.cs

示例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;
        }
开发者ID:iliasjennane,项目名称:pokerleaguemanager,代码行数:15,代码来源:OptimisticConcurrencyException.cs

示例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);
     }
 }
开发者ID:wra222,项目名称:testgit,代码行数:14,代码来源:UnitOfWork.cs

示例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;
 }
开发者ID:ialekseev,项目名称:Anodyne,代码行数:6,代码来源:ConcurrencyException.cs

示例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))
		{
		}
开发者ID:Kostassoid,项目名称:Nerve.EventStore,代码行数:5,代码来源:ConcurrencyException.cs

示例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);
        }
开发者ID:key-value,项目名称:enode,代码行数:19,代码来源:DefaultCommandExecutor.cs

示例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);
            }
        }
开发者ID:sgmunn,项目名称:Mobile.CQRS,代码行数:13,代码来源:AggregateRepository.cs

示例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);
        }
开发者ID:key-value,项目名称:enode,代码行数:10,代码来源:DefaultEventSourcingService.cs

示例13: IncreaseAggregateVersion

 private void IncreaseAggregateVersion(IAggregateRoot aggregateRoot)
 {
     _increaseVersionMethodDict[aggregateRoot.GetType()](aggregateRoot);
 }
开发者ID:key-value,项目名称:enode,代码行数:4,代码来源:DefaultEventSourcingService.cs


注:本文中的IAggregateRoot.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。