I've inherited a class which has a bunch of properties defined as:
public int ID
{
get { return m_nOID; }
set { m_nOID = value; }
}
public int ConxnDetail
{
get { LoadDetails(); return m_nConxnDetail; }
set { m_nConxnDetail = value; }
}
public bool ConxnConstraints
{
get { LoadDetails(); return m_bConxnConstraints; }
set { m_bConxnConstraints = value; }
}
public bool IsShowCables
{
get { LoadDetails(); return m_bIsShowCables; }
set { m_bIsShowCables = value; }
}
public int DefaultQueue
{
get { LoadDetails(); return m_nDefaultQueue; }
set { m_nDefaultQueue = value; }
}
private User LoadDetails()
{
if (!IsLoaded && !IsNew)
{
Logger.InfoFormat("Loading user details. UserID: [{0}]", m_nOID);
User user = RemoteActivator.Create<RemoteUser>().GetUserById(m_nOID);
if (user != null)
{
CopyDetails(user);
MarkLoaded();
}
else
ClearDetails();
}
return this;
}
I would absolutely love to clean up the conventions here a bit and use only automatic getters/setters. Is this possible to do? If not, any other suggestions on reducing the boilerplate needed?