AOP Extensions

A few refinements to the AOP IL generator since this morning (addition of boxing for value types and some minor tweaks) and everything is working wonderfully:


 

// SAMPLE ATTRIBUTES
// ...


public
class UseConstraintsAttribute : Attribute, IPreprocessMethodCall

{

public void PreprocessMethodCall(MethodInfo method, object[] parameters)

{

Constraints.EnsureValid(method, parameters);

}

}



public class NotNullAttribute : ParameterConstraintAttribute

{

public override void EnsureValid(object o)

{

if(o == null) throw new ConstraintViolationException("Parameter cannot be null");

}

}

 

// ...

// SAMPLE CLASS

public
class TestClass

{

[Activehead.AOP.UseConstraints]

public virtual int Test([OneOf(new object[] { 0,1,3 })]int i, [Match("[A-Z]+")]string s2)

{

return 0;

}

[Activehead.AOP.UseConstraints]

public virtual void Test2([MinElements(1)] int[] values)

{

}

}

No Comments