public static void SaveAllContextOnThread()
        {
            if (!IsExistContextStackOnThread())
            {
                Thread.SetData(_slot, new Stack <ContextStack>());
            }
            ContextStack contextStack = new ContextStack();

            if (ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                contextStack.ConditionBean = ConditionBeanContext.GetConditionBeanOnThread();
            }
            if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
            {
                contextStack.OutsideSqlContext = OutsideSqlContext.GetOutsideSqlContextOnThread();
            }
            if (FetchNarrowingBeanContext.IsExistFetchNarrowingBeanOnThread())
            {
                contextStack.FetchNarrowingBean = FetchNarrowingBeanContext.GetFetchNarrowingBeanOnThread();
            }
            if (InternalMapContext.IsExistInternalMapOnThread())
            {
                contextStack.InternalMap = InternalMapContext.GetInternalMap();
            }
            GetContextStackOnThread().Push(contextStack);
        }
        public static void RestoreAllContextOnThreadIfExists()
        {
            if (!IsExistContextStackOnThread())
            {
                return;
            }
            Stack <ContextStack> stackOnThread = GetContextStackOnThread();

            if (stackOnThread.Count == 0)
            {
                ClearContextStackOnThread();
                return;
            }
            ContextStack  contextStack = stackOnThread.Pop();
            ConditionBean cb           = contextStack.ConditionBean;

            if (cb != null)
            {
                ConditionBeanContext.SetConditionBeanOnThread(cb);
            }
            OutsideSqlContext outsideSqlContext = contextStack.OutsideSqlContext;

            if (outsideSqlContext != null)
            {
                OutsideSqlContext.SetOutsideSqlContextOnThread(outsideSqlContext);
            }
            FetchNarrowingBean fetchNarrowingBean = contextStack.FetchNarrowingBean;

            if (fetchNarrowingBean != null)
            {
                FetchNarrowingBeanContext.SetFetchNarrowingBeanOnThread(fetchNarrowingBean);
            }
            IDictionary <String, Object> internalMap = contextStack.InternalMap;

            if (internalMap != null)
            {
                InternalMapContext.ClearInternalMapOnThread();
                foreach (String key in internalMap.Keys)
                {
                    Object value = internalMap[key];
                    InternalMapContext.SetObject(key, value);
                }
            }
        }
 protected void RestoreAllContextOnThreadIfExists()
 {
     ContextStack.RestoreAllContextOnThreadIfExists();
 }
 protected void ClearAllCurrentContext()
 {
     ContextStack.ClearAllCurrentContext();
 }
 protected void SaveAllContextOnThread()
 {
     ContextStack.SaveAllContextOnThread();
 }