best way to track field and property changes?

  • Thread starter Thread starter PJ6
  • Start date Start date
P

PJ6

What's the best way to, in the general case, track changes to an object's
public fields and properties? In a lot of applicatoins I've seen bahavior
consistant with simple periodic checking from a timer, or checking otherwise
initiated from a user event. I don't believe I can make that approach work
in the project I'm working on... are there other ways to do this, where I
can actually get an event raised on a field change, that don't involve using
dynamically emitted wrapper types?

Paul
 
What's the best way to, in the general case, track changes to an object's
public fields and properties? In a lot of applicatoins I've seen bahavior
consistant with simple periodic checking from a timer, or checking otherwise
initiated from a user event. I don't believe I can make that approach work
in the project I'm working on... are there other ways to do this, where I
can actually get an event raised on a field change, that don't involve using
dynamically emitted wrapper types?

Paul

Is this object one you created or one you don't have the source
available to? The simplest way to track changes (imo) is to fire an
event from the Set accessor of the property if the value changed. If
you can't modify the source, perhaps you could inherit the class and
add the functionality? If you don't have the source, and can't inherit/
override the properties things will be more difficult.

Thanks,

Seth Rowe
 
PJ6 said:
What's the best way to, in the general case, track changes to an object's
public fields and properties? In a lot of applicatoins I've seen bahavior
consistant with simple periodic checking from a timer, or checking otherwise
initiated from a user event. I don't believe I can make that approach work
in the project I'm working on... are there other ways to do this, where I
can actually get an event raised on a field change, that don't involve using
dynamically emitted wrapper types?

If you take the Windows Controls as an example, they all seem to sport
lots of *Changed events that get raised when the associated Property is
... er .. changed (e.g. TextChanged, SelectedIndexChanged, EnabledChanged).

"track changes to an object's public /fields/"?
Not a chance. If you expose a field, then you won't have the slightest
idea how or when it gets changed. Wrap it up in a Property.

HTH,
Phill W.
 
Phill W. said:
"track changes to an object's public /fields/"?
Not a chance. If you expose a field, then you won't have the slightest
idea how or when it gets changed. Wrap it up in a Property.

Yep, that's what I thought. No getting around having to use IL... but this
will solve a problem I've been thinking about for years. More advanced than
I would have liked, but probably worth the investment.

Paul
 
Back
Top