Archive

Cache

Custom Attribute That Caches
public class CacheAttribute : OnMethodInvocationAspect
{
    public override void OnInvocation(MethodInvocationEventArgs eventArgs)
    {
        object value;
        string key = // Compute the cache key (details omitted).

        if (!cache.TryGetValue(key, out value))
        {
            lock ( this )
            {
                if (!cache.TryGetValue(key, out value))
                {  
                    eventArgs.Proceed();
                    value = eventArgs.ReturnValue;
                    cache.Add(key, value);
                    return;
                } 
            }
        }
        eventArgs.ReturnValue = value;
    }
}

About

What Is PostSharp?

PostSharp is a Post-Compiler 

PostSharp is inserts itself in the build process and post-processes the compiled assembly. Since PostSharp works at MSIL level, it supports virtually all static languages targeting the .NET Framework.

PostSharp is an Aspect-Oriented Framework

PostSharp brings Aspect-Oriented Programming (AOP) to the Microsoft .NET Framework. Better: PostSharp makes AOP pragmatic and goes to the point.

Aspect-Oriented Programming takes note that traditional object-oriented programming don't offer any satisfying solution to a whole class of problems.

For instance, we cannot implement tracing, exception handling, thread synchronization or most of other technical requirements (aka non-functional requirements) without adding a lot of redundant code to every single method requiring these behaviors. And there can be hundreds.

PostSharp and AOP help in restoring the principle of separation of concerns by offering a way to better encapsulate technical requirements into aspects:

  1. Technical requirements are encapsulated as aspects, which are plain C#/VB classes.
  2. Aspects are applied to business objects without invading the source code of business methods.
  3. At build time, aspects are injected into business methods.

PostSharp is Extensible

From the first line of code, PostSharp has been designed as an extensible platform for post-processing of .NET assemblies. All analysis and transformations are encapsulated into tasks, which are packaged into plug-ins and loaded in the platform. This platform is named PostSharp Core, while we group under the term PostSharp all the members of this product family.

Most of people use existing plug-ins, like PostSharp Laos. They do not need any extensive knowledge of PostSharp Core and MSIL. If you have more specific requirements, or if you are an Independent Software Vendor producing development tools, you may want to develop your own plug-ins, or even to integrate the platform into your existing tools.

PostSharp Architecture

 

Login and Registration Problems

So you have problems registering or logging into our website?

The following tips usually help:

  1. Check your spam box. You should have received an activation email. You will not be able to sign in until you follow the URL contained in this email.
  2. Wait 5 minutes. As a spam protection, some email providers require the activation email to be resent after a few minutes. So be patient!
  3. Verify your password. Because of a bug in the Joomla/PHPBB software we use, passwords cannot contain non-ASCII characters. Reset your password if necessary.

If you still have problems, don't contact us at login@postsharp.org. Don't forget to tell us the login and email address you used during registration.