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


C# IServiceLocator.Release方法代码示例

本文整理汇总了C#中IServiceLocator.Release方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.Release方法的具体用法?C# IServiceLocator.Release怎么用?C# IServiceLocator.Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceLocator的用法示例。


在下文中一共展示了IServiceLocator.Release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplayEvents

 /// <summary>
 /// Rebuilds all read models. This is a potentially lengthy operation!
 /// </summary>
 public static void ReplayEvents(IServiceLocator locator)
 {
     if (!initialized) throw new InvalidOperationException("The event store must be initialized before first usage.");
     IDocumentStore documentStore = null;
     try
     {
         documentStore = (IDocumentStore)locator.Resolve(typeof(IDocumentStore));
         DoReplayEvents(locator, documentStore);
     }
     finally
     {
         if (documentStore != null)
             locator.Release(documentStore);
     }
 }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:18,代码来源:EventStore.cs

示例2: DoReplayEvents

        private static void DoReplayEvents(IServiceLocator locator, IDocumentStore documentStore)
        {
            // wait for indexing to complete
            WaitForIndexing(documentStore);

            // delete all read models
            documentStore.DatabaseCommands.DeleteByIndex("ReadModelIndex", new IndexQuery());

            // load all event streams and dispatch events
            var dispatcher = new EventDispatcher(locator);

            var current = 0;
            while (true)
            {
                IDocumentSession session = null;

                try
                {
                    session = (IDocumentSession)locator.Resolve(typeof(IDocumentSession));
                    var eventsQuery =
                        session.Query<EventsIndex.Result, EventsIndex>()
                               .Customize(
                                   x => x.WaitForNonStaleResultsAsOf(DateTime.Now.AddSeconds(15)))
                               .OrderBy(x => x.ChangeSequence);
                    var results = eventsQuery.Skip(current).Take(128).ToList();
                    if (results.Count == 0) break;
                    foreach (var result in results)
                    {
                        var changeSequence = result.ChangeSequence;
                        var ids = result.Id.Select(x => x.Id);
                        var streams = session.Load<EventStream>(ids);

                        var events = from stream in streams
                                     from @event in stream.History
                                     where @event.ChangeSequence == changeSequence
                                     orderby @event.TimeStamp
                                     select new { stream.Id, Event = @event };
                        foreach (var item in events)
                        {
                            dispatcher.Dispatch(item.Event, item.Id);
                        }
                    }

                    session.SaveChanges();
                    current += results.Count;
                }
                finally
                {
                    if (session != null)
                        locator.Release(session);
                }
            }
        }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:53,代码来源:EventStore.cs


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