28 lines
764 B
C#
28 lines
764 B
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MegaRobo.RRQuartz;
|
|
|
|
public class JobManagerProvider
|
|
{
|
|
private readonly IDictionary<string, JobManager> _sources = new ConcurrentDictionary<string, JobManager>(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;
|
|
}
|
|
} |