Esempio n. 1
0
 /// <summary>
 /// This method is invoked when the
 /// <see cref="ISessionFactoryHolder"/>
 /// instance needs a session instance. Instead of creating one it interrogates
 /// the active scope for one. The scope implementation must check if it
 /// has a session registered for the given key.
 /// <seealso cref="RegisterSession"/>
 /// </summary>
 /// <param name="key">an object instance</param>
 /// <returns>
 ///     <c>true</c> if the key exists within this scope instance
 /// </returns>
 public override bool IsKeyKnown(object key)
 {
     if (parentTransactionScope != null)
     {
         return(parentTransactionScope.IsKeyKnown(key));
     }
     if (ParentScope != null)
     {
         return(ParentScope.IsKeyKnown(key));
     }
     return(Key2Session.ContainsKey(key));
 }
Esempio n. 2
0
 public override void RegisterSession(object key, ISession session)
 {
     if (parentTransactionScope != null)
     {
         parentTransactionScope.RegisterSession(key, session);
         return;
     }
     if (ParentScope != null)
     {
         ParentScope.RegisterSession(key, session);
     }
     if (!Key2Session.ContainsKey(key))
     {
         Key2Session.Add(key, session);
     }
 }
Esempio n. 3
0
        public override ISession GetSession(object key)
        {
            if (parentTransactionScope != null)
            {
                return(parentTransactionScope.GetSession(key));
            }

            var session = ParentScope == null
                              ? Key2Session[key]
                              : ParentScope.GetSession(key);

            if (!Key2Session.ContainsKey(key))
            {
                Key2Session.Add(key, session);
            }

            Initialize(session);
            return(session);
        }