title: Basic implementation of AOP like attribute using standard .NET Framework
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2206554/c-sharp-wrap-method-via-attributes">C# wrap method via attributes</a>  </p>
  </blockquote>
  
  
  
  <p>I'd like to achieve such functionality:</p>
  
  <pre><code>[Atomic]
  public void Foo()
  {           
      /* foo logic */
  }
  </code></pre>
  
  <p>Where <code>[Atomic]</code> attribute is an attribute, which wraps function logic within a transaction scope:</p>
  
  <pre><code>using(var scope = new TransactionScope())
  {
      /* foo logic */
      scope.Complete();
  }
  </code></pre>
  
  <p>How to write such an attribute? </p>
  
  <p>I've asked before basically the same <a href="https://stackoverflow.com/questions/14294977/attribute-which-wraps-functionality-of-its-decorated-function-within-some-outer">question</a>, I know this can be done using AOP, but I didn't mention I'm searching for some simplest proof of concept implementation or helpful articles which can help me to write this using pure .NET Framework (I suppose using <code>RealProxy</code> and <code>MarshalByRefObject</code> types, about which I've read browsing related questions). </p>
  
  <p>I need to solve exactly this shown example. It seems like a basic thing so I want to learn how to do it starting from scratch. It doesn't need to be safe and flexible for now.</p>