I need to limit some function regarding license . so i created an attribute using MethodInterceptionAspect in postSharp and validate the fields i need. is there any other 3rd party making aop custom attributes ? i know dynamic proxy is exist but i want the annotation part also.
Example :
namespace ConsoleApp1
{
[Serializable]
public class LicenseValidator : MethodInterceptionAspect
{
readonly String name;
public LicenseValidator(String name)
{
this.name = name;
}
public override void OnInvoke(MethodInterceptionArgs args)
{
if (name = ! "notInvoke")
{
args.Proceed();
}
else
Console.WriteLine("Not executed !");
}
}
}
And the usage of this :
[LicenseValidator("tal")]
public static Boolean PrintHi(int num)
{
Console.WriteLine("Hi");
return true;
}
NOTE : it's just an example for the usage and isn't my code. but this is the method i want to use in order to solve my problem.
Any other way to achieve it with attributes? 3rd party or manually.
Thanks !
you can use other 3rd party such Spring.NET, Castle Windsor, Aspect.NET and etc. or you can use Ioc Container such as Unity or StractureMap and etc.
PostSharp is CompileTime and other are runTime.
and also can use AspectInjector
.
It is very simple and also CompileTime
like postSharp .
You can see this link to how to use it.
I hope it will be useful