brady gaster

yadnb

AOP + XPath Expressions = XPath in Attributes

This might be a little premature but I'm curious per a pet project I'm working on which uses the aforementioned technologies together. Here's the question, for which I hope you'd like to provide an answer, your own ideas, pontifications, and that sort of thing. Would you find useful something that made the code below possible. I'm just providing this code as a "starting point" for discussion, based on some preliminary code/design work I've done. So yes, this is real stuff, that's "out there" if you'd like to take a peek. Hence the need for discussion.

Sorry for the re-posting of this, but I'm having all sorts of issues with the code colorizers I've tried. No luck whatsoever, in fact. To solve said issue, click use this link.

Comments

Jb Evain said:

Hello,

Using custom attributes can be a way to work on the AOP paradigm on .net, but people have to be careful, it's easy to use them to tag the base code, indicating where the aspects code should be called... In the AOP paradigm, aspects describes where they applies.

This is implemented in an aspect weaver called AspectDNG, as well as a pure form, where pointcuts are described in an XML file appart.

You can take a look at thoses samples:

http://www.dotnetguru2.org/jbevain/index.php?p=132&more=1&c=1&tb=1&pb=1
http://www.dotnetguru2.org/jbevain/index.php?p=134&more=1&c=1&tb=1&pb=1

Regards
# May 10, 2005 4:12 PM

Chris Martin said:

Looks pretty swell to me! ;)
# May 10, 2005 4:40 PM

brady gaster said:

JB, I'm not sure if your comment is relevant to this particular implementation. Sure, there's a lot of discussion and/or kvetching lately about the legitimacy of AOP in .Net, but let's argue that point some other day.

Put it this way - if you could use Attributes to control functional flow in the fashion I've put forth here, would it be something you'd regard as useful?
# May 10, 2005 6:39 PM

AndrewSeven said:

I'm not sure I get it, I've seen something that looks very similar that was for parameter validation.

Are you using XPathCheckMethod(...) to provide information for AOP maybe the names are throwing me..

What will you query with the xPath?


p.s. I clicked one of JB's links and it seems to be an AOP frame written in C#
# May 10, 2005 7:42 PM

brady gaster said:

True, it is a frame written in C#, but it seemed somewhat more "ubiquitous" in nature, whereas the topic I'm supposing is - well - the implementation of an XPath-driven business-logic functionality set.

Think of it like this - you serialize an object to its XML structure. Then you run XPath queries on it. Should the XPath rules (simplistic at this juncture) yield an empty nodeset, the rules "fail," semantically speaking, since they find no matches.
# May 10, 2005 9:10 PM

JosephCooney said:

If Account implemented IXPathNavigator and BaseXrpContextPersister inherited from contextboundobject you could do this already (couldn't you?).
# May 10, 2005 11:54 PM

Jb Evain said:

Hey Brady,

Sorry if i was wrong, your example is a little bit short. Here you add some business logic using custom attributes (pre & post invariants conditions). XPath is a good choice, maybe you can take a look at some OPath implementation.

Is not the process of serializing the object then applying the rules a little bit long ?
# May 11, 2005 7:24 AM

brady gaster said:

Joseph - That's correct. Account does indeed implement an abstract class [BaseXrpContextPersister] which implements ContextBoundObject. So yes, I'm intercepting the method call prior to it's execution, then serializing (which, yes JB, is somewhat slow, I'd love to discuss with ya), then running XPath.

Never heard of OPath, I'll have to google...
# May 11, 2005 8:49 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)