public void Test_CreateInstance_NoCallback_ThrowException() { object instance = null; Action callback = () => SingletonHelper.GetInstance(ref instance, null); callback.Should().Throw <ArgumentException>(); }
//@El Conserje call it ConserjeCore or I'll scream public EnigmaticThunderPlugin() { LogCore.logger = base.Logger; //Add listeners. BepInEx.Logging.Logger.Listeners.Add(new ErrorListener()); BepInEx.Logging.Logger.Listeners.Add(new ChainLoaderListener()); SingletonHelper.Assign <EnigmaticThunderPlugin>(ref EnigmaticThunderPlugin.instance, this); GatherModules(); var networkCompatibilityHandler = new NetworkCompatibilityHandler(); networkCompatibilityHandler.BuildModList(); RoR2.RoR2Application.isModded = true; ErrorListener.vanillaErrors.addition += VanillaErrors_addition; ErrorListener.modErrors.addition += ModErrors_addition; ChainLoaderListener.OnChainLoaderFinished += OnChainLoaderFinished; SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; }
/// <summary> /// Gets the connection string for the DaoContext with the specified logical name. /// The component will first check if any call has been made to SetContextConnectionString /// then check the default configuration (app.config or web.config) returning an empty string /// if the connection string is not found. /// </summary> /// <param name="contextName">The logical name returned by the implementation of /// DaoObject.ContextName.</param> /// <returns>A database connection string to be used for the specified logicalName.</returns> public static string GetContextConnectionString(string contextName) { if (contexts == null) { contexts = SingletonHelper.GetApplicationProvider <DaoContextStore>(new DaoContextStore()); } if (staticConnectionStrings != null && staticConnectionStrings.ContainsKey(contextName)) { return(staticConnectionStrings[contextName]); } if (contexts != null && contexts.ContainsKey(contextName)) { return(contexts[contextName].ConnectionString); } string property = DefaultConfiguration.GetProperty(typeof(DaoContext).Name, contextName);//CascadeConfiguration.GetProperty(logicalName, true, typeof(DaoContext)); if (property.StartsWith("$")) { string propertyName = property.Replace("$", ""); if (propertyName.Equals(contextName)) { throw new InvalidOperationException("Invalid DaoContext $ reference. Must not be the same name as the context or Stack overflow will occur"); } property = GetContextConnectionString(propertyName); } return(property); }
public static void SendDataBoxScriptResponse(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; string clientKey = request.QueryString["ck"]; BoxResponses responses = SingletonHelper.GetApplicationProvider <BoxResponses>(); string script; if (!responses.ContainsKey(clientKey)) { script = "// no scripts"; } else { script = responses[clientKey].Script; } responses.Remove(clientKey); response.Clear(); response.Write(script); response.Flush(); response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); //response.End(); }
public void Awake() { Instance = SingletonHelper.Assign(Instance, this); LogSpawnCards = Config.Bind("SpawnCards", "LogToConsole", false, "Log all available spawn cards from \"SpawnCards/CharacterSpawnCards/\""); CustomSpawnCards = Config.Bind("SpawnCards", "CustomSpawnCards", "SpawnCards/CharacterSpawnCards/cscJellyfish; SpawnCards/CharacterSpawnCards/cscRoboBallMini", "Semi-colon seperated (;) entries of Spawn Cards"); if (LogSpawnCards.Value) { List <String> allPaths = new List <string>(); LegacyResourcesAPI.GetAllPaths(allPaths); foreach (var resource in allPaths) { if (resource.StartsWith("SpawnCards/CharacterSpawnCards/")) { Debug.LogError(resource); } } } // FIXME: Get rid of this hack and just use a prefab On.RoR2.NetworkSession.BeginRun += NetworkSession_BeginRun; // This is the real way to integrate // GameModeCatalog.getAdditionalEntries += RegisterVIPRun; }
public void TearDown() { lock (Lock) { SingletonHelper.CleanUpAfterTest(); _isRunning = false; } }
void Awake() { if (SingletonHelper.ThrowExceptionDestroyGameObject(ref _instance, this) != this) { return; } viewportCamera.OnReoriented += RedrawWorld; }
private IUnitOfWork GetUnitOfWorkInstance() { return(SingletonHelper.GetInstance(ref _unitOfWork, () => { var appSettings = ConfigurationHelper.GetValues(_databaseJsonKey); return new UnitOfWorkFactory().Create(new ConnectionFactory(appSettings[0])); })); }
private static EventManager GetEventManager() { if (current == null) { current = SingletonHelper.GetApplicationProvider <EventManager>(new EventManager()); } return(current); }
// Token: 0x060024A3 RID: 9379 RVA: 0x000AB869 File Offset: 0x000A9A69 public void OnDisable() { SteamworksLobbyManager.onLobbyLeave -= this.OnLobbyLeave; if (!GameNetworkManager.singleton.isNetworkActive) { SteamworksLobbyManager.LeaveLobby(); } MultiplayerMenuController.instance = SingletonHelper.Unassign <MultiplayerMenuController>(MultiplayerMenuController.instance, this); }
public static void Initialize(IExecutorService executorService, FFTgtHandlerDeviceTypes deviceType, Func <IFFMsgTransmitter> createMessageHandler) { _currentHelper = new SingletonHelper <FFMsgHandlerFactory>( new Lazy <FFMsgHandlerFactory>( () => new FFMsgHandlerFactory(executorService, createMessageHandler) { DeviceType = deviceType, })); }
public void Test_CreateInstance_Return_NewInstance() { const string expected = "Instance"; string instance = null; var result = SingletonHelper.GetInstance(ref instance, () => expected); result.Should().NotBeNull(); result.Should().Be(expected); }
// Token: 0x060005F6 RID: 1526 RVA: 0x0001893D File Offset: 0x00016B3D private void OnEnable() { ArenaMissionController.instance = SingletonHelper.Assign <ArenaMissionController>(ArenaMissionController.instance, this); Action action = ArenaMissionController.onInstanceChangedGlobal; if (action != null) { action(); } SceneDirector.onPreGeneratePlayerSpawnPointsServer += this.OnPreGeneratePlayerSpawnPointsServer; }
// Token: 0x060024A2 RID: 9378 RVA: 0x000AB82C File Offset: 0x000A9A2C public void OnEnable() { this.LerpAllUI(LerpUIRect.LerpState.Entering); this.state = MultiplayerMenuController.State.Idle; MultiplayerMenuController.instance = SingletonHelper.Assign <MultiplayerMenuController>(MultiplayerMenuController.instance, this); if (!SteamworksLobbyManager.isInLobby) { SteamworksLobbyManager.CreateLobby(); } SteamworksLobbyManager.onLobbyLeave += this.OnLobbyLeave; }
public void OnDisable() { SingletonHelper.Unassign <EnigmaticThunder>(EnigmaticThunder.instance, this); Action awake = EnigmaticThunder.onDisable; if (awake == null) { return; } awake(); }
public static void SendBoxResponse(HttpContext context, string templateName) { HttpResponse response = context.Response; string clientKey = context.Request.QueryString["ck"]; if (string.IsNullOrEmpty(clientKey)) { throw new JsonInvalidOperationException("No client key was specified"); } BoxResponses boxResponses = SingletonHelper.GetApplicationProvider <BoxResponses>(); if (IsScriptRequest(context.Request)) { response.Clear(); response.Write(boxResponses[clientKey].Script); boxResponses.Remove(clientKey); response.Flush(); response.SuppressContent = true; context.ApplicationInstance.CompleteRequest(); return; } string virtualBoxPath = GetVirtualBoxPath(context, templateName); try { if (string.IsNullOrEmpty(virtualBoxPath)) { throw new JsonInvalidOperationException("The box template file could not be found: [" + templateName + "]"); } // this is the dom id of the requesting "box" div element string requesterId = context.Request.QueryString["domid"]; // TODO: enumify magic strings BoxResponse boxResponse = GetBoxResponse(context, virtualBoxPath, null, true); boxResponses.Add(clientKey, boxResponse); response.Clear(); response.Write(boxResponse.Html); response.Flush(); response.SuppressContent = true; context.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { SendBoxedError(context, ex); } return; }
public void OnDisable() { SingletonHelper.Unassign <Plugin>(Plugin.instance, this); Log.LogI("Henry instance unassigned."); Action awake = Plugin.onDisable; if (awake == null) { return; } awake(); }
// Token: 0x060005F7 RID: 1527 RVA: 0x00018970 File Offset: 0x00016B70 private void OnDisable() { SceneDirector.onPreGeneratePlayerSpawnPointsServer -= this.OnPreGeneratePlayerSpawnPointsServer; ArenaMissionController.instance = SingletonHelper.Unassign <ArenaMissionController>(ArenaMissionController.instance, this); Action action = ArenaMissionController.onInstanceChangedGlobal; if (action == null) { return; } action(); }
private void Start() { gManager = SingletonHelper.Find(SingletonEnums.GameManager).GetComponent <GameManager>(); cManager = SingletonHelper.Find(SingletonEnums.CustomisationManager).GetComponent <CustomisationManager>(); var winnerID = gManager.QueryStats(GetWinningOrder).First(); if (winnerID < gManager.GameData.HumanCount) { DragonHelper.SetDragonAsPlayer(cManager.GetPlayerCustomisation(winnerID), dragon); } UpdateDisplay(winnerID, gManager.GetPlayerStatsData(winnerID)); }
private static bool SendProviderInfo(HttpContext context) { HttpResponse response = context.Response; JsonProviders providers = SingletonHelper.GetSessionSingleton <JsonProviders>(); string providerInfoJson = JsonSerializer.ToJson(providers.ProviderInfos); string providerInfoScript = @"JSUI.providerInfo = " + providerInfoJson + ";\r\n"; providerInfoScript += "JSUI.providerInfo = JSUI.toDictionary(\"VarName\", JSUI.providerInfo);"; response.Clear(); response.Write(providerInfoScript); response.Flush(); response.SuppressContent = true; return(true); }
private static ILogger GetLogger() { ILogger logger = SingletonHelper.GetApplicationProvider <ILogger>(); if (logger != null) { return(logger); } else { InitializeLogManager(); return(currentLog); } }
public static void Initialize(IExecutorService executorService, bool perThreadFactory, ExecutionStepDeviceTypes deviceType) { _currentHelper = new SingletonHelper <ExecutionStepFactory>( new Lazy <ExecutionStepFactory>( () => new ExecutionStepFactory(executorService) { DeviceType = deviceType, })); //var lazyFactory = new Lazy<_ExecutionStepFactory>(() => new _ExecutionStepFactory(_entities, _gmuExecutionStepsExecuting)); //if (perThreadFactory) // _factoryHelper = new SingletonThreadHelper<_ExecutionStepFactory>(lazyFactory); //else // _factoryHelper = new SingletonHelper<_ExecutionStepFactory>(lazyFactory); }
internal static void SetProvider(object handlerInstance, Page page) { Type serverHandler = handlerInstance.GetType(); if (serverHandler == typeof(RuntimeTypeHandle)) { return; } JsonProviders providers = SingletonHelper.GetSessionSingleton <JsonProviders>();//if (javascriptHandlers == null) JsonProviderInfo provider = providers.Add(handlerInstance); if (page != null) { RegisterClientInitScript(page, provider); } }
// Token: 0x06001035 RID: 4149 RVA: 0x000474E0 File Offset: 0x000456E0 private void OnEnable() { PreGameController.instance = SingletonHelper.Assign <PreGameController>(PreGameController.instance, this); if (NetworkServer.active) { this.RecalculateModifierAvailability(); } NetworkUser.OnNetworkUserUnlockablesUpdated += this.OnNetworkUserUnlockablesUpdatedCallback; NetworkUser.OnPostNetworkUserStart += this.OnPostNetworkUserStartCallback; if (NetworkClient.active) { foreach (NetworkUser networkUser in NetworkUser.readOnlyLocalPlayersList) { networkUser.SendServerUnlockables(); } } }
// Don't override in derived classes, override PostOnDestroy instead void OnDestroy() { // Only clear the instance if this object is the instance if (instance != null) { if (instance.Equals(this)) { SingletonHelper <GameObjectType> .HandleOnDestroy(ref instance, ref blockInstanceFetch); PostOnDestroy(); } } else { Debug.LogError("Destroying an object when the instance of the singleton is null, this should not happen (unless you change scripts at runtime in the editor)!\n Type is " + typeof(GameObjectType).ToString()); } }
private void Start() { gManager = SingletonHelper.Find(SingletonEnums.GameManager).GetComponent <GameManager>(); cManager = SingletonHelper.Find(SingletonEnums.CustomisationManager).GetComponent <CustomisationManager>(); if (gManager) { var humanCount = gManager.GameData.HumanCount; var aiCount = gManager.GameData.AICount; var playersDragons = Enumerable .Range(0, humanCount) .Select(i => { var dragon = CreateDragon(i); DragonHelper.SetDragonAsPlayer( cManager.GetPlayerCustomisation(i), dragon); return(dragon); }); var aiDragons = Enumerable .Range(humanCount, aiCount) .Select(i => CreateDragon(i)); dragons = playersDragons.Concat(aiDragons).ToArray(); } else /* Standalone Scene Mode */ { dragons = FindObjectsOfType <DragonController>() .Select(drc => drc.gameObject) .ToArray(); foreach (var dragon in dragons) { alivePlayers.Add(dragon); dragon.GetComponent <DamageController>().onDeath += OnDragonDeath; } } PositionPlayers(); }
internal void Initialize(bool throwIfRequiredPropertiesNotFoundInDefaultConfig) { if (currentLog == null || currentLog.IsNull) { DefaultConfiguration.SetProperties(this, false); currentLog = CreateLogger(this.logType); //if (this.logType == Naizari.Logging.LogType.MSSql) //{ // EventManager.Current.EventStoreType = EventStoreTypes.MSSql.ToString(); //} //else //{ // EventManager.Current.EventStoreType = EventStoreTypes.SQLite.ToString(); //} currentLog.Initialize(); DefaultConfiguration.SetPropertiesByProxy(currentLog, this, throwIfRequiredPropertiesNotFoundInDefaultConfig); } SingletonHelper.SetApplicationProvider <ILogger>(currentLog, true); WireNotificationEvents(currentLog); }
static void Main(string[] args) { Console.WriteLine("Enter one of the following number to explore the design pattern"); Console.WriteLine("1- Singleton Pattern"); Console.WriteLine("2- Singleton Thread Safety with lock Pattern"); string value = Console.ReadLine(); switch (value) { case "1": Singleton objectA = Singleton.GetInstance; objectA.PrintDetails("This is from Object A"); Singleton objectB = Singleton.GetInstance; objectA.PrintDetails("This is from Object B"); //Uncomment following code if we want to test why we need to seal our class. //Singleton.DerivedSingleton derivedObj = new Singleton.DerivedSingleton(); //derivedObj.PrintDetails("From Derived"); break; case "2": Parallel.Invoke( () => SingletonHelper.PrintObjectA1Details(), () => SingletonHelper.PrintObjectB1Details() ); break; case "3": SingletonEager objectAE = SingletonEager.GetInstance; objectAE.PrintDetails("This is from eager loading, obeject AE"); SingletonEager objectBE = SingletonEager.GetInstance; objectAE.PrintDetails("This is from eager loading, obeject BE"); break; case "D": break; } Console.Read(); }
public void Setup() { while (true) { if (!_isRunning) { lock (Lock) { if (!_isRunning) { _isRunning = true; break; } } } Thread.Sleep(10); } lock (Lock) { SingletonHelper.CleanUpAfterTest(); } }
public static void Initialize(IExecutorService executorService, bool perThreadFactory, ExecutionStepDeviceTypes deviceType) { _currentHelper = new SingletonHelper<ExecutionStepFactory>( new Lazy<ExecutionStepFactory>( () => new ExecutionStepFactory(executorService) { DeviceType = deviceType, })); //var lazyFactory = new Lazy<_ExecutionStepFactory>(() => new _ExecutionStepFactory(_entities, _gmuExecutionStepsExecuting)); //if (perThreadFactory) // _factoryHelper = new SingletonThreadHelper<_ExecutionStepFactory>(lazyFactory); //else // _factoryHelper = new SingletonHelper<_ExecutionStepFactory>(lazyFactory); }
static ExMonitorServerConfigStoreFactory() { _singletonHelper = new SingletonHelper<IExMonitorServerConfigStore>(Create); }
// Token: 0x0600257E RID: 9598 RVA: 0x000A318B File Offset: 0x000A138B private void OnDisable() { SingletonHelper.Unassign <SteamJoinClipboardLobby>(ref SteamJoinClipboardLobby.instance, this); }
public static void Initialize(IExecutorService executorService) { _currentHelper = new SingletonHelper<MonitorHandlerFactory>( new Lazy<MonitorHandlerFactory>( () => { return new MonitorHandlerFactory(executorService); })); }
public static void Initialize(IExecutorService executorService, FFTgtHandlerDeviceTypes deviceType, Func<IFFMsgTransmitter> createMessageHandler) { _currentHelper = new SingletonHelper<FFMsgHandlerFactory>( new Lazy<FFMsgHandlerFactory>( () => new FFMsgHandlerFactory(executorService, createMessageHandler) { DeviceType = deviceType, })); }