Z
Zac
Alright anyone who has 2c throw it in...
I am working through a custom xml serializer and have come upon a
conundrum, given our class design.
The interface implemented on the base class (base for all business
entities) dictates that the implementing class expose a Dirty property
(for state).
The base class (that actually manages state, once for all inheritors)
maintains an array of Dirty (bools) and each class down the chain
knows (internally) the index in the array based on its level in the
heirarchy.
StateMgr (bool[] dirty)
- BaseEntity
- Person (dirty[0] = false)
- Employee (dirty[1] = false)
- Manager (dirty[2] = true)
Given the above, each entity overrides the Dirty property from the
base and via the override hides the indexing of the Dirty property (so
I could call manager.Dirty = true instead of manager.Dirty[2] = true).
Now in the serializer, I want to be able to serialize all of the
exposed properties PLUS the Dirty value for each of the entities in
the chain. In the resulting xml I would have something like <Manager
Dirty="true false false" ... indicating that only the properties in my
StateMgr need be updated.
Getting long - but stick with me. The Dirty property is exposed
through the interface so if I cast my Manager to an Employee the Dirty
property through that interface is false (given the above), and in
turn if I cast down to a Person then I also get the dirty property at
the Person index (0) which is false.
The problem is, I will only have "some object" when I serialize. I can
use the GetType().BaseType to see the base type - but I know of no way
to actually cast to that type (i.e. Employee tempObject = manager as
Employee) but using dyanmic properties like (Employee tempObject =
manager as Manager.GetType().BaseType)...
....therein lies the problem, that I'm dealing with...
....thoughts? questions? snide remarks? dirty jokes?
I am working through a custom xml serializer and have come upon a
conundrum, given our class design.
The interface implemented on the base class (base for all business
entities) dictates that the implementing class expose a Dirty property
(for state).
The base class (that actually manages state, once for all inheritors)
maintains an array of Dirty (bools) and each class down the chain
knows (internally) the index in the array based on its level in the
heirarchy.
StateMgr (bool[] dirty)
- BaseEntity
- Person (dirty[0] = false)
- Employee (dirty[1] = false)
- Manager (dirty[2] = true)
Given the above, each entity overrides the Dirty property from the
base and via the override hides the indexing of the Dirty property (so
I could call manager.Dirty = true instead of manager.Dirty[2] = true).
Now in the serializer, I want to be able to serialize all of the
exposed properties PLUS the Dirty value for each of the entities in
the chain. In the resulting xml I would have something like <Manager
Dirty="true false false" ... indicating that only the properties in my
StateMgr need be updated.
Getting long - but stick with me. The Dirty property is exposed
through the interface so if I cast my Manager to an Employee the Dirty
property through that interface is false (given the above), and in
turn if I cast down to a Person then I also get the dirty property at
the Person index (0) which is false.
The problem is, I will only have "some object" when I serialize. I can
use the GetType().BaseType to see the base type - but I know of no way
to actually cast to that type (i.e. Employee tempObject = manager as
Employee) but using dyanmic properties like (Employee tempObject =
manager as Manager.GetType().BaseType)...
....therein lies the problem, that I'm dealing with...
....thoughts? questions? snide remarks? dirty jokes?