Re: Accessor Issue
- From: "Bruce Wood" <brucewood@xxxxxxxxxx>
- Date: 13 Apr 2005 10:32:10 -0700
>> The first is to change the IsDirty property of Facility to check
each
>> of its aggregate components, like this:
>> public bool IsDirty
>> {
>> get
>> {
>> return this.dirty || this.address.IsDirty || this...IsDirty
||
>> ...;
>> }
>> }
> well, i cant to that, because the facility is derived from a base
> class, and the base class carry all those isDirty, isNew... flags and
> some other important things..
> see my code before... ( ..base.MarkDirty(); )
Yes, you still can. You should do it like this:
public class BaseClass
{
private bool _isDirty = false;
...
public void MakeDirty()
{
this._isDirty = true;
}
public virtual bool IsDirty
{
get { return this._isDirty; }
}
}
public class Facility : BaseClass
{
private Address _facilityAddress;
...
public override bool IsDirty
{
get { return base.IsDirty || this._facilityAddress.IsDirty ||
.... ; }
}
}
You should have an IsDirty property anyway... nobody should be looking
at the local isDirty flag in the base class. That should be private.
So, all you do is declare the property virtual and then override it in
classes that have complex fields like Addresses and PhoneNumbers.
I think that this is much cleaner and easier than messing with events,
etc.
.
- Follow-Ups:
- Re: Accessor Issue
- From: Steven Wolf
- Re: Accessor Issue
- References:
- Accessor Issue
- From: Steven Wolf
- Re: Accessor Issue
- From: Bruce Wood
- Re: Accessor Issue
- From: Steven Wolf
- Accessor Issue
- Prev by Date: Re: Don't know how to view submitted values.
- Next by Date: process packet with deviceiocontrol
- Previous by thread: Re: Accessor Issue
- Next by thread: Re: Accessor Issue
- Index(es):