I have a class, where I use the singleton-pattern. The class looks like
public class MessageAccess
{
private static MessageAccess instance;
public static MessageAccess Instance
{
get { return instance ?? (instance = new MessageAccess()); }
}
private MessageAccess()
{
}
public void Initialize(string data)
{
//...
isInitialized = true;
}
private bool isInitialized;
public void ReadData1()
{
// This Method can always be called
}
public void ReadData2()
{
// This Method can only be called, if Initialize was called. Otherwise an exception will be thrown
}
}
Is it possible to generate a compiler-warning if the Method Initialize
is never called