public static void SetAccessContextOnThread(AccessContext context)
 {
     if (context == null)
     {
         String msg = "The argument[context] must not be null.";
         throw new ArgumentNullException(msg);
     }
     Thread.SetData(_accessContextSlot, context);
 }
 public static DateTime?GetAccessTimestampOnThread()
 {
     if (IsExistAccessContextOnThread())
     {
         AccessContext userContextOnThread = GetAccessContextOnThread();
         DateTime?     accessTimestamp     = userContextOnThread.AccessTimestamp;
         if (accessTimestamp != null)
         {
             return(accessTimestamp);
         }
     }
     return(DateTime.Now); // as Default
 }
        public static String GetAccessModuleOnThread()
        {
            if (IsExistAccessContextOnThread())
            {
                AccessContext userContextOnThread = GetAccessContextOnThread();
                String        accessModule        = userContextOnThread.AccessModule;
                if (accessModule != null)
                {
                    return(accessModule);
                }
            }
            String msg;

            if (IsExistAccessContextOnThread())
            {
                msg = "The access module was not found in AccessContext on thread: " + GetAccessContextOnThread();
            }
            else
            {
                msg = "The AccessContext was not found on thread!";
            }
            throw new SystemException(msg);
        }
        public static Object GetAccessValueOnThread(String key)
        {
            if (IsExistAccessContextOnThread())
            {
                AccessContext userContextOnThread           = GetAccessContextOnThread();
                IDictionary <String, Object> accessValueMap = userContextOnThread.AccessValueMap;
                if (accessValueMap != null)
                {
                    return(accessValueMap[key]);
                }
            }
            String msg;

            if (IsExistAccessContextOnThread())
            {
                msg = "The access value was not found in AccessContext on thread:";
                msg = msg + " key=" + key + " " + GetAccessContextOnThread();
            }
            else
            {
                msg = "The AccessContext was not found on thread: key=" + key;
            }
            throw new SystemException(msg);
        }