title: Postsharp get intercepted method return type
body: <p>How can I get the return type of the intercepted method? I am writing a method level caching mechanism and I want to use postsharp to intercept the method calls. However,I need to be able to cast my stored object to the original method type.</p>
  
  <pre><code> public override void OnEntry(MethodExecutionArgs InterceptedItem)
      {
          if (_instance==null)
              _instance = new CouchbaseClient();
  
  
  
          string Key = GetCacheKey(InterceptedItem);
  
  
          var CacheItem = _instance.Get(Key);
  
          if (CacheItem != null)
          {
              // The value was found in cache. Don't execute the method. Return immediately.
              //string StringType = (String)_instance.Get(Key+"Type");
              JavaScriptSerializer jss = new JavaScriptSerializer();
              InterceptedItem.ReturnValue = jss.Deserialize&lt;Object&gt;(CacheItem.ToString());
              //Type Type = Type.GetType(StringType);
              InterceptedItem.ReturnValue = (Object)InterceptedItem.ReturnValue;
                 // jss.Deserialize(CacheItem.ToString(), Type.GetType(StringType));
              InterceptedItem.FlowBehavior = FlowBehavior.Return;
          }
          else
          {
              // The value was NOT found in cache. Continue with method execution, but store 
              // the cache key so that we don't have to compute it in OnSuccess.
              InterceptedItem.MethodExecutionTag = Key;
          }
      }
  </code></pre>