postsharp - AOP - Injecting a property with a dynamically computed value -
(or "using locationinterceptionaspect , iinstancescopedaspect together")
using postsharp i'm trying inject property target class using 'introducemember' , using 'ongetvalue' functionality of locationinterceptionaspect dynamically give value on inspection.
originally thought i'd need 2 separate aspects, 1 field injection , 1 location interception managed combine 2 implementing iinstancescopedaspect interface , inheriting locationinterceptionaspect.
the problem if set breakpoint see property that's been injected, if set breakpoint in ongetvalue method (that gets fired each property on class) can't see it...
here's sample code:
[serializable] class daldecoratorwrapper : locationinterceptionaspect, iinstancescopedaspect { public override void ongetvalue(locationinterceptionargs args) { if (args.locationname == "type") { args.value = "computed value here"; } args.proceedgetvalue(); } [introducemember(overrideaction = memberoverrideaction.overrideorfail)] public string type { get; set; }
i hoping there improve way of doing overriding ongetvalue that's called each getter want target getter of property that's been injected
cheers
aop postsharp
No comments:
Post a Comment