I have a class like this
internal class Report
{
public Company TargetCompany { get; private set; }
.... // other stuff
}
I do not want any one to be able to do this
Report r = GetReport();
Company c = r.TargetCompany;
but instead always use
r.TargetCompany
when they want access to the Company variable.
Is that possible? Does that even make sense?
You can expose a proxy interface in Report, which calls the equivalent interface in Company, and make Company private, so that you completely control (encapsulate even) access to the Company object.