question about passing object references,Me and serialisation
I have a class called Person. It inherits from a base class PersistentObject
that exposes Load() and Save() functions and contains an ObjectID.
I WANT to write the Load() method like this:
PersistentManager.LoadObject(Me) 'where Me is a By Ref parameter
The persistence layer uses .NET serialisation to return a populated object,
based on the persons ObjectId which must be populated when Load() is called.
(or does a refresh). It also examines other properties of the PersistentObject,
such as whether this is a proxy object or not.
Now the problem. Me cannot be assigned a new object. Likewise making the
parameter in LoadObject() By Ref and passing it Me does not work (interestingly
it compiles without complaint but simply does not change).
So I have resorted to making Load() a method that returns the newly loaded
object, meaning I have to write the ugly code:
dim oObj as PersistentObject
and in the main program:
when what I want to be able to write is
It's nice having Load() a method of the object, rather than having to call
a function in the persistance layer. Any idea's on how I could get the object
to change itself to the new object, within the Load() method, or solve this
design problem someother way? Guess I am missing something because this must
be a common scenario
If not I guess the best thing is to put a method on the PersistanceManager
so I can write
Then there are no problems having Person being passed by ref and returning
a new object. (PersistenceManager is a singleton)
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center