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


C# IIdentity.ToString方法代码示例

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

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

示例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;
        }
开发者ID:jaceenet,项目名称:TastyDomainDriven,代码行数:13,代码来源:EventStoreAsync.cs

示例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);
            }
        }
开发者ID:11646729,项目名称:iSeismic,代码行数:17,代码来源:InMemoryStore.cs

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

示例6: IdentityToString

 string IdentityToString(IIdentity id)
 {
     // in this project all identities produce proper name
     return id.ToString();
 }
开发者ID:frankies,项目名称:lokad-iddd-sample,代码行数:5,代码来源:EventStore.cs


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