/// <summary> /// Private constructor of a Session object. /// </summary> /// <remarks> /// The lack of public constructors forces the singleton model. /// </remarks> private Session(ScreenManager screenManager, GameplayScreen gameplayScreen) { // check the parameter if (screenManager == null) { throw new ArgumentNullException("screenManager"); } if (gameplayScreen == null) { throw new ArgumentNullException("gameplayScreen"); } // assign the parameter this.screenManager = screenManager; this.gameplayScreen = gameplayScreen; }
/// <summary> /// Start a new session based on the data provided. /// </summary> public static void StartNewSession(ScreenManager screenManager, GameplayScreen gameplayScreen) { if (screenManager == null) { throw new ArgumentNullException("screenManager"); } if (gameplayScreen == null) { throw new ArgumentNullException("gameplayScreen"); } // end any existing session EndSession(); // create a new singleton singleton = new Session(screenManager, gameplayScreen); }