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


C# ISession.Dispose方法代码示例

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


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

示例1: FinalizeSession

        private static void FinalizeSession(ISession session)
        {
            if (session == null || !session.IsOpen)
                return;

            try
            {
                if (session.Transaction != null && session.Transaction.IsActive)
                {
                    session.Flush();
                    session.Transaction.Commit();
                }
            }
            catch (Exception)
            {
                if (session.Transaction != null)
                    session.Transaction.Rollback();

                throw;
            }
            finally
            {
                session.Close();
                session.Dispose();
            }
        }
开发者ID:armw4,项目名称:dubb-load,代码行数:26,代码来源:SessionFactory.cs

示例2: EndSession

        private static void EndSession(ISession session, bool commitTransaction = true)
        {
            try {
                if (session.Transaction != null && session.Transaction.IsActive) {
                    if (commitTransaction) {
                        try {
                            session.Transaction.Commit();
                        }
                        catch {
                            session.Transaction.Rollback();
                            throw;
                        }
                    }
                    else {
                        session.Transaction.Rollback();
                    }
                }
            }
            finally {
                if (session.IsOpen)
                    session.Close();

                session.Dispose();
            }
        }
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:25,代码来源:SessionPerRequestModule.cs

示例3: RebuildDatabase

        public void RebuildDatabase()
        {
            ITransaction transaction = null;
            try
            {
                var factoryFactory = new NHibernateSessionFactory();
                ISessionFactory sessionFactory = factoryFactory.GetSessionFactory();
                string[] dropScripts = factoryFactory.Configuration.GenerateDropSchemaScript(((ISessionFactoryImplementor)sessionFactory).Dialect);
                string[] createScripts = factoryFactory.Configuration.GenerateSchemaCreationScript(((ISessionFactoryImplementor)sessionFactory).Dialect);

                session = sessionFactory.OpenSession();
                ExecuteScripts(dropScripts, session.Connection);
                ExecuteScripts(createScripts, session.Connection);
                SaveScripts(createScripts, "create.sql");

                transaction = session.BeginTransaction();
                var repository = new Repository(session);
                var data = new Data();
                data.Build(repository);
            }
            finally
            {
                if (session != null)
                {
                    if (transaction != null && transaction.IsActive)
                    {
                        transaction.Commit();
                    }
                    session.Close();
                    session.Dispose();
                }
            }
        }
开发者ID:liammclennan,项目名称:shortest-path,代码行数:33,代码来源:Db.cs

示例4: Init

        public void Init() {
            _session = _sessionFactory.OpenSession();
            foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
                foreach (var killRecord in _session.CreateCriteria(killType).List()) {
                    _session.Delete(killRecord);
                }
            }
            _session.Flush();
            _session.Close();
            _session.Dispose();
            _session = _sessionFactory.OpenSession();

            var builder = new ContainerBuilder();
            builder.RegisterAutoMocking();
            builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
            builder.RegisterType(typeof(SettingsFormatter)).As(typeof(ISettingsFormatter));
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();

            _container = builder.Build();

        }
开发者ID:Golone,项目名称:Orchard,代码行数:27,代码来源:ContentDefinitionManagerTests.cs

示例5: EndSession

        private static void EndSession(ISession session)
        {
            if (session.Transaction != null && session.Transaction.IsActive) {
                session.Transaction.Commit();
            }

            session.Dispose();
        }
开发者ID:iamsingularity,项目名称:Sharp-Lite,代码行数:8,代码来源:SessionPerRequestModule.cs

示例6: CloseTransaction

 private void CloseTransaction(ISession session)
 {
     try
     {
         session.Transaction.Commit();
         session.Transaction.Dispose();
     }
     catch
     {
         session.Transaction.Rollback();
         session.Dispose();
     }
     finally
     {
         session.Dispose();
     }
 }
开发者ID:richinoz,项目名称:ToDo,代码行数:17,代码来源:NHibernateModule.cs

示例7: DisposeOfSession

        public virtual void DisposeOfSession(ISession session)
        {
            if (!CanDisposeOfSession(session))
            {
                return;
            }

            session.Dispose();
        }
开发者ID:jahansha,项目名称:SessionManager,代码行数:9,代码来源:SessionManager.cs

示例8: ProcessRequest

 public override void ProcessRequest(HttpContext context)
 {
     Session = NHWebConsoleSetup.OpenSession();
     try {
         Session.FlushMode = FlushMode.Never;
         base.ProcessRequest(context);
     } finally {
         if (NHWebConsoleSetup.DisposeSession)
             Session.Dispose();
     }
 }
开发者ID:MathieuDSTP,项目名称:NHWebConsole,代码行数:11,代码来源:NHController.cs

示例9: EndSession

 private static void EndSession(ISession session, HttpApplication application)
 {
     //TODO: What about rollbacks? => what to do then?
     //error module do the rollbacks?
     //transaction isn't automatically rollbacked!
     if (application.Context.Error != null && session.Transaction != null && session.Transaction.IsActive)
     {
         session.Transaction.Rollback();
     }
     else if (session.Transaction != null && session.Transaction.IsActive)
     {
         session.Transaction.Commit();
     }
     session.Dispose();
 }
开发者ID:Detroier,项目名称:playground,代码行数:15,代码来源:NHibernateSessionModule.cs

示例10: Init

        public void Init(HttpApplication application)
        {
            application.BeginRequest += delegate
                                        {
                                            CurrentSession = _sessionFactory.OpenSession();
                                        };

            application.EndRequest += delegate
                                      {
                                          if (CurrentSession != null)
                                          {
                                              CurrentSession.Dispose();
                                          }
                                      };
        }
开发者ID:alberto,项目名称:altnerddinner,代码行数:15,代码来源:NhSessionPerRequestModule.cs

示例11: InitializeLibspotify

        public static void InitializeLibspotify()
        {
            Session = SessionFactory.CreateSession(
                Constants.ApplicationKey,
                Constants.CacheFolder,
                Constants.SettingsFolder,
                Constants.UserAgent);

            Application.Current.Exit += delegate
            {
                if (Session != null)
                {
                    Session.Dispose();
                }
            };
        }
开发者ID:kms,项目名称:torshify-client,代码行数:16,代码来源:SpotifyModule.cs

示例12: SessionIs_

        protected void SessionIs_(string action)
        {
            switch (action)
            {
                case Opened:
                    Session = OpenSession();
                    Assert.That(Session.IsOpen);
                    break;

                case Closed:
                    Session.Close();
                    Assert.That(!Session.IsOpen);
                    Session.Dispose();
                    break;
            }
        }
开发者ID:gwhn,项目名称:Weblitz.MessageBoard,代码行数:16,代码来源:IntegrationTestBase.cs

示例13: ReleaseSession

 /// <summary>
 /// Releases the specified session
 /// </summary>
 /// <param name="session"></param>
 public void ReleaseSession(ISession session)
 {
     if (!threadScopeInfo.HasInitializedScope)
     {
         session.Flush();
         session.Dispose();
     }
 }
开发者ID:ArionWM,项目名称:ActiveRecord,代码行数:12,代码来源:SessionFactoryHolder.cs

示例14: Setup

        public void Setup()
        {
            blog = new Blog();
            post1 = new Post();
            post2 = new Post();
            post1.Blog = blog;
            post2.Blog = blog;

            session = factory.OpenSession();
            session.Save(blog);
            session.Save(post1);
            session.Save(post2);
            session.Dispose();

            session = factory.OpenSession();
        }
开发者ID:rcarrillopadron,项目名称:nhibernategenerics,代码行数:16,代码来源:CheckingLazyLoading.cs

示例15: DisposeSession

        /// <summary>
        /// Close the specified session
        /// </summary>
        /// <param name="sessionToClose">session to close</param>
        public void DisposeSession(ISession sessionToClose) {
            if(IsDebugEnabled)
                log.Debug("NHibernate 세션 및 Connection을 닫습니다...");

            //explicit disposing of connection is required (??) for in memory databases
            //
            if(sessionToClose != null) {
                var conn = sessionToClose.Connection;
                sessionToClose.Dispose();
                if(conn != null)
                    conn.Dispose();

                if(IsDebugEnabled)
                    log.Debug("NHibernate 세션 및 Connection을 닫았습니다.");
            }
        }
开发者ID:debop,项目名称:NFramework,代码行数:20,代码来源:UnitOfWorkTestContext.cs


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