#region Apache Notice /***************************************************************************** * $Header: $ * $Revision: $ * $Date: $ * * iBATIS.NET Data Mapper * Copyright (C) 2004 - Gilles Bayon * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ********************************************************************************/ #endregion #region Using using System.Runtime.Remoting.Messaging; #endregion namespace IBatisNet.DataMapper { /// /// Summary description for SessionHolder. /// /// /// See also LocalDataStoreSlot /// public class SessionHolder { #region Constants /// /// Token for SqlMapConfig xml root. /// private const string LOCAL_SESSION = "_IBATIS_LOCAL_SQLMAP_SESSION_"; #endregion #region Fields private string _sessionName = string.Empty; #endregion #region Constructor (s) / Destructor /// /// Constructor /// /// SqlMapper identifiant public SessionHolder(string sqlMapperId) { _sessionName = LOCAL_SESSION + sqlMapperId; } #endregion #region ISessionContainer Members #region Properties /// /// Get the local session /// public SqlMapSession LocalSession { get { return CallContext.GetData(_sessionName) as SqlMapSession; } } #endregion #region Methods /// /// Store the local session on the container. /// Ensure that the session is unique for each thread. /// /// The session to store public void Store(SqlMapSession session) { CallContext.SetData(_sessionName, session); } /// /// Remove the local session from the container. /// public void Dispose() { CallContext.SetData(_sessionName, null); } #endregion #endregion } }