Ejemplo n.º 1
0
 public static object GetObject(this Thread key)
 {
     Contract.Requires <ArgumentNullException>(key != null);
     lock (g_pLookGetObj)
     {
         if (g_pGetObject == null)
         {
             ParameterExpression g_pThread = Expression.Parameter(typeof(Thread));
             FieldInfo           g_pField  = ThreadUnit.GetObjectField();
             g_pGetObject = Expression.Lambda <Func <Thread, object> >(Expression.Field(g_pThread, g_pField), g_pThread).Compile();
         }
     }
     return(g_pGetObject(key));
 }
Ejemplo n.º 2
0
 public static void SetObject(this Thread key, object value)
 {
     Contract.Requires <ArgumentNullException>(key != null);
     lock (g_pLookSetObj)
     {
         if (g_pSetObject == null)
         {
             ParameterExpression g_pThread = Expression.Parameter(typeof(Thread));
             FieldInfo           g_pField  = ThreadUnit.GetObjectField();
             ParameterExpression g_pState  = Expression.Parameter(typeof(object));
             g_pSetObject = Expression.Lambda <Action <Thread, object> >(Expression.Assign(Expression.Field(g_pThread, g_pField), g_pState),
                                                                         g_pThread, g_pState).Compile();
         }
     }
     g_pSetObject(key, value);
 }