Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created January 6, 2018 23:49
Show Gist options
  • Save aramkoukia/ad93d9d4307dbb081609f0858c0594a9 to your computer and use it in GitHub Desktop.
Save aramkoukia/ad93d9d4307dbb081609f0858c0594a9 to your computer and use it in GitHub Desktop.
Cache Attribute
using System;
using Unity;
using Unity.Interception.PolicyInjection.Pipeline;
using Unity.Interception.PolicyInjection.Policies;
namespace CachingAspectOrientedImplemetation
{
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public class CacheAttribute : HandlerAttribute
{
public string KeyPrefix { get; set; }
public CacheAttribute(string keyPrefix)
{
KeyPrefix = keyPrefix;
}
public override ICallHandler CreateHandler(IUnityContainer container)
{
return new CacheAttributeHandler(this.KeyPrefix);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment