class Program
{
static void Main(string[] args)
{
Master m = new Master(37);
Content c = new Content(m);
}
}
I have two classes defined. The first as follow:
internal class Content
{
private Master _parentMaster;
private Content _contentChildren;
#region Constructor
internal Content(Master master)
{
this._parentMaster = master;
}
internal Content(Master master, long contentId)
{
this._parentMaster = master;
_getContent(contentId);
}
#endregion
#region Private Methods
private void _getContent(long contentId)
{
contentRepository.getContent(contentId, _parentMaster.MasterId);
}
#endregion
#region Internal Methods
internal void AddContent()
{
// code omitted
}
internal void UpdateContent()
{
// code omitted
}
internal void GetChildren()
{
// code imitted
}
internal void GetRootContent()
{
// code omitted
}
#endregion
#region Properties
// code omitted
#endregion
}
and the second one:
public class Master
{
private MasterEntities _master;
private List<Master> _masters;
#region Constructor
internal Master()
{
_master = new MasterEntities();
}
internal Master(long masterId)
{
_getMaster(masterId);
}
#endregion
#region Private Methods
internal void _getMaster()
{
// code omitted
}
#region Properties
internal long MasterId
{
get
{
return _master.id;
}
set
{
_master.id = value;
}
}
// code omitted
#endregion
}
Is this the correct way to implement the two classes? Or will be better to implement Nested Classes? If yes, how to get the same result stated in "Main" with nested classes?
IList<T>. Actually In that case I would recommend theComposite pattern.IList<T>implementation of the master manage the data relations.