samedi 2 juin 2018

How to allow singleton class to be initiate with passing different param via constructor

i have a class in my project and i want it to initiate only once with passing specific parameter via constructor , but when i pass different parameter it should initiate.how i can achieve this with singleton design pattern. or suggest me any other design pattern if this couldn't achieve with singleton .

class Program
{
static void Main()
{
    SiteStructure s = SiteStructure.Instance;
}
}

public sealed class SiteStructure
{
static readonly SiteStructure _instance = new SiteStructure();
public static SiteStructure Instance
{
    get
    {
        return _instance;
    }
}
SiteStructure()
{
    // Initialize.
}
}

Aucun commentaire:

Enregistrer un commentaire