Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves the <see cref="IRulesetConfigManager"/> for a <see cref="Ruleset"/>.
        /// </summary>
        /// <param name="ruleset">The <see cref="Ruleset"/> to retrieve the <see cref="IRulesetConfigManager"/> for.</param>
        /// <returns>The <see cref="IRulesetConfigManager"/> defined by <paramref name="ruleset"/>, null if <paramref name="ruleset"/> doesn't define one.</returns>
        /// <exception cref="InvalidOperationException">If <paramref name="ruleset"/> doesn't have a valid <see cref="RulesetInfo.ID"/>.</exception>
        public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
        {
            if (ruleset.RulesetInfo.ID == null)
            {
                return(null);
            }

            return(configCache.GetOrAdd(ruleset.RulesetInfo.ID.Value, _ => ruleset.CreateConfig(settingsStore)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the <see cref="IRulesetConfigManager"/> for a <see cref="Ruleset"/>.
        /// </summary>
        /// <param name="ruleset">The <see cref="Ruleset"/> to retrieve the <see cref="IRulesetConfigManager"/> for.</param>
        /// <returns>The <see cref="IRulesetConfigManager"/> defined by <paramref name="ruleset"/>, null if <paramref name="ruleset"/> doesn't define one.</returns>
        /// <exception cref="InvalidOperationException">If <paramref name="ruleset"/> doesn't have a valid <see cref="RulesetInfo.ID"/>.</exception>
        public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
        {
            if (ruleset.RulesetInfo.ID == null)
            {
                throw new InvalidOperationException("The provided ruleset doesn't have a valid id.");
            }

            return(configCache.GetOrAdd(ruleset.RulesetInfo.ID.Value, _ => ruleset.CreateConfig(settingsStore)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves the <see cref="IRulesetConfigManager"/> for a <see cref="Ruleset"/>.
        /// </summary>
        /// <param name="ruleset">The <see cref="Ruleset"/> to retrieve the <see cref="IRulesetConfigManager"/> for.</param>
        /// <returns>The <see cref="IRulesetConfigManager"/> defined by <paramref name="ruleset"/>, null if <paramref name="ruleset"/> doesn't define one.</returns>
        /// <exception cref="InvalidOperationException">If <paramref name="ruleset"/> doesn't have a valid <see cref="RulesetInfo.ID"/>.</exception>
        public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
        {
            if (!configCache.TryGetValue(ruleset.RulesetInfo.ShortName, out var config))
            {
                // any ruleset request which wasn't initialised on startup should not be stored to realm.
                // this should only be used by tests.
                return(ruleset.CreateConfig(null));
            }

            return(config);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Retrieves the <see cref="IRulesetConfigManager"/> for a <see cref="Ruleset"/>.
        /// </summary>
        /// <param name="ruleset">The <see cref="Ruleset"/> to retrieve the <see cref="IRulesetConfigManager"/> for.</param>
        /// <returns>The <see cref="IRulesetConfigManager"/> defined by <paramref name="ruleset"/>, null if <paramref name="ruleset"/> doesn't define one.</returns>
        /// <exception cref="InvalidOperationException">If <paramref name="ruleset"/> doesn't have a valid <see cref="RulesetInfo.ID"/>.</exception>
        public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
        {
            if (ruleset.RulesetInfo.ID == null)
            {
                throw new InvalidOperationException("The provided ruleset doesn't have a valid id.");
            }

            if (configCache.TryGetValue(ruleset.RulesetInfo.ID.Value, out var existing))
            {
                return(existing);
            }

            return(configCache[ruleset.RulesetInfo.ID.Value] = ruleset.CreateConfig(settingsStore));
        }