A
Alex
Hello,
Is it possible to have a class that has "readonly" properties for some
classes and can be written by others?
The reason I want this is that some of my classes need to expose their
"status", but I need to be ensure that this is only updated by the class
that "owns" them, and is not updateable by anything else. Also, I'd rather
these classes pass their "status" by reference instead of by value, so any
other object querying this "status" will have an up-to-date view of the
value.
The status of the classes I mentioned is not a simple string or enum, but
rather a more complex type, such as
class Status
{
string Name = "N/A";
string TypeName = "N/A";
enState State = enState.Unknown;
int MessagesProcessed = 0;
etc...
}
Right now I have something like (forgive the pseudocode)...
class Worker1 : WorkerBase
{
private Status m_Status = new Status();
Worker1()
{
// do work - private methods will update values within "m_Status"
object
}
public Status MyStatus
{ get { return m_Status; } }
}
I hope I'm making sense! Let me know if I need to clarify anything...
Cheers,
Alex
Is it possible to have a class that has "readonly" properties for some
classes and can be written by others?
The reason I want this is that some of my classes need to expose their
"status", but I need to be ensure that this is only updated by the class
that "owns" them, and is not updateable by anything else. Also, I'd rather
these classes pass their "status" by reference instead of by value, so any
other object querying this "status" will have an up-to-date view of the
value.
The status of the classes I mentioned is not a simple string or enum, but
rather a more complex type, such as
class Status
{
string Name = "N/A";
string TypeName = "N/A";
enState State = enState.Unknown;
int MessagesProcessed = 0;
etc...
}
Right now I have something like (forgive the pseudocode)...
class Worker1 : WorkerBase
{
private Status m_Status = new Status();
Worker1()
{
// do work - private methods will update values within "m_Status"
object
}
public Status MyStatus
{ get { return m_Status; } }
}
I hope I'm making sense! Let me know if I need to clarify anything...
Cheers,
Alex