I have the following type :
// incomplete class definition
public class Person
{
private string name;
public string Name
{
get { return this.name; }
}
}
I want this type to be created and updated with some sort of dedicated controller/builder, but I want it to remain read-only for other types.
This object also needs to fire an event every time it is updated by its controller/builder.
To summary, according to the previous type definition skeleton :
- The
Person
could only be instantiated by a specific controller - This controller could update the state of the
Person
(name
field) at any time - The
Person
need to send a notification to the rest of the world when it occurs - All other types should only be able to read
Person
attributes
How should I implement this ? I'm talking about a controller/builder here, but all others solutions are welcome.
Note : I would be able to rely on the internal
modifier, but ideally all my stuff should be in the same assembly.