I have a class below that I implemented as a Singleton, and added few methods to use with and without parameters, leaving off the details:
public class LogManager
{
public static LogManager Instance
{
get
{
return instance;
}
}
public LogManager Create(Guid productId)
{
_productId = productId;
return Instance;
}
public LogManager Create()
{
return Instance;
}
public void WriteStateChangeEvent()
{
}
}
Is there any way to restrict calling Instance
directly so it can be called like this LogManager.Instance.Create(newProductId).WriteStateChangeEvent()
or LogManager.Instance.Create().WriteStateChangeEvent()
but never like this LogManager.Instance.WriteStateChangeEvent()
This is not a general OOP Singleton pattern question but a question about specific implementation