using System; using System.Collections.Concurrent; using System.Collections.Generic; namespace MegaRobo.RRQuartz; public class JobManagerProvider { private readonly IDictionary _sources = new ConcurrentDictionary(StringComparer.CurrentCultureIgnoreCase); public JobManager GetOrAdd(string name) { return this._sources.TryGetValue(name, out JobManager service) ? service : this.Create(name); } public JobManager Create(string name) { var service = new JobManager(); if(this._sources.ContainsKey(name)) { this._sources[name] = service; } else { this._sources.TryAdd(name, service); } return service; } }