Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
org.puremvc.csharp.patterns.facade.facade.cs, line 368protected static IFacade instance = new Facade();
org.puremvc.csharp.patterns.facade.facade.cs, line 368protected static IFacade instance;
public static ApplicationFacade getInstance() { if (instance == null) instance = new ApplicationFacade(); return instance as ApplicationFacade; }
In org.puremvc.csharp.patterns.facade.Facade.cs /// <summary> /// A simple object that can be shared between threads as a locking mechanism /// </summary> protected static object _sharedObject = new object(); /// <summary> /// Facade Singleton Factory method /// </summary> /// <returns>The Singleton instance of the Facade</returns> public static IFacade getInstance() { lock (_sharedObject) { if (instance == null) instance = new Facade(); } return instance; }.... /// <summary> /// The Singleton Facade Instance /// </summary> protected static IFacade instance;
public static ApplicationFacade getInstance() { lock (_sharedObject) { if (instance == null) instance = new ApplicationFacade(); } return instance as ApplicationFacade; }
public class Singleton { private final static Singleton INSTANCE = new Singleton(); // Private constructor suppresses generation of a (public) default constructor private Singleton() {} public static Singleton getInstance() { return INSTANCE; } }
1 public static ApplicationFacade getInstance()2 {3 if (instance == null)4 {5 instance = new ApplicationFacade();6 }7 return instance as ApplicationFacade;8 }
1 private ApplicationFacade() {}23 static ApplicationFacade()4 {5 instance = new ApplicationFacade();6 }78 public static new ApplicationFacade getInstance()9 {10 return instance as ApplicationFacade;11 }