access parent class?

  • Thread starter Thread starter Justin Rich
  • Start date Start date
J

Justin Rich

i have a class Workstations which inherits collectionbase.
basically Workstations is a collection of Workstation's

my workstations collection has a property called ValidatedCount

the workstation class has a method called Validate()

what i would like to do is use the Workstations class to have a count
(inherited from collectionbase) and have a ValidatedCount...

how do i access the parent class to increase the ValidatedCount property
from the Workstion object in the Workstations class?

Thanks
Justin
 
i have a class Workstations which inherits collectionbase.
basically Workstations is a collection of Workstation's

my workstations collection has a property called ValidatedCount

the workstation class has a method called Validate()

what i would like to do is use the Workstations class to have a count
(inherited from collectionbase) and have a ValidatedCount...

how do i access the parent class to increase the ValidatedCount property
from the Workstion object in the Workstations class?

There's no natural concept of a "parent" in this case - after all,
unless you've specifically precluded it, a Workstation could be part
of multiple Workstations collections.

Does it take long to validate a Workstation instance? If not, I'd just
make the ValidateCount iterate through all the Workstation instances
in the collection and call Validate on each of them.

Jon
 
i have a class Workstations which inherits collectionbase. basically
Workstations is a collection of Workstation's

my workstations collection has a property called ValidatedCount

the workstation class has a method called Validate()

what i would like to do is use the Workstations class to have a count
(inherited from collectionbase) and have a ValidatedCount...

how do i access the parent class to increase the ValidatedCount
property from the Workstion object in the Workstations class?

Thanks
Justin

I don't think you can, as there is no way to identity that "parent".

Some ways around it (that I see):
1. don't remember that "validatedcount" in your collection, but loop through
all workstations, counting the validated ones.
2. add a "collection" property to your workstation class. When you add a
workstation to the collection (using an overridden Add method), set that
property. Then you have a way to notify the collection of validation.
3. Add a "validated" event to the workstation class. When it's validated
the workstation class raises that event. The collection needs to have
a handler registered that updates the count.

Can a workstation become "unvalidated" or can it be dropped from the
collection? That should decrease the validated count!

Hans Kestin
 
Back
Top