c# - Wrapper for code block -


for example have datagrid , want before databinding , after databinding, so:

dgvtasksdoclist.savelayouttofile(); statuschangesextendedbindingsource.datasource = dt; dgvtasksdoclist.restorelayoutfromfile(); 

and want add such code cases when binding sources. there easy way write such code before/after action(sure can add 2 lines, may there known way of doing such things)?

seems case aop - http://en.wikipedia.org/wiki/aspect-oriented_programming.

for example postsharp able create attribute persistlayout , apply this:

[persistlayout] public void binddatasource(object dt) {     statuschangesextendedbindingsource.datasource = dt; } 

then postsharp extent source-code @ compile-time invoke additional two-lines.

other idea might invoke these 2 methods in statuschangesextendedbindingsource.datasource property setter decision needs lot more context know.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -