开发者

aop eventinterceptionaspect postsharp

What would be the best practice to implement save/restore layout funcionality for every DeveloperExpress XtraGrid control in my application. I use开发者_StackOverflow a lot of Grid visual elements on every winform in my application (GridControl, LookUpEdit, SearchLookUpEdit...) and currently I'm poluting every winform with load/unload events that call save/restore functionality for each Grid element on that form manually. I already have an extension method that makes saving/restoring Grids a matter of one function call now I want to have one centralized class where I would take care for saving/restoring each Grid type in my application.

I'm new to aop but could something like this be done with tools like postsharp and a global eventinterceptionaspect where load/unload events would be applied to each Grid type that gets initialised in my assembly?


Yes, you can intercept events using PostSharp. You can check out the following article to get a walk-through http://www.sharpcrafters.com/blog/post/PostSharp-Principals-Day-11-e28093-Interception-e28093-Part-3.aspx

You can build an aspect that just calls out to your extension methods when the event is fired. Aspects can be applied globally to save you some work using multicasting http://www.sharpcrafters.com/blog/post/Day-2-Applying-Aspects-with-Multicasting-Part-1.aspx http://www.sharpcrafters.com/blog/post/Day-3-Applying-Aspects-with-Multicasting-Part-2.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜