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
Post a Comment