Hey all
I've recently implemented a singleton class, and within it I've declared a static generic list of (T) class. Anyway this is my first attempt at using singleton but everything I've tried work so far.
My Question: To be consistent, I don't want the MasterSiteData to be visible to other classes except my Singleton class. I thought of maybe encapsulating both classes within a parent class which would give me new options. However I'd rather have some of the great opinions you all provide :).
public sealed class Singleton
{
private static readonly Singleton Instance = new Singleton();
private Singleton()
{
}
public static List<MasterSiteData> MasterDetails = new List<MasterSiteData>();
}
public class MasterSiteData
{
public Guid GuidId { get; set; }
public string Uri { get; set; }
public int LinkNumber { get; set; }
public MasterSiteData(Guid guid, string uri, int linknumber)
{
GuidId = guid;
Uri = uri;
LinkNumber = linknumber;
}
}
EDIT:
Crap! I totally forgot that I need to instantiate the MasterSiteData class to add a record to my list, therefore I really can't have it hidden, for example
Singleton.MasterDetails.Add(new MasterSiteData(Guid.NewGuid(), "lol1", 1337));