public static void AddToCache(WorkBenchServiceType singletonType, IWorkBenchService singleton) { if (_singletonCache.ContainsKey(singletonType)) { throw new ArgumentException("type", $"The SingletonType '{singletonType.ToString()}' has been already set. Only one Workbench service of a given type is allowed."); } _singletonCache.Add(singletonType, singleton); }
private static void InitializeServices() { // Foreach service registered on WorkBench cache, the Initialize method should be called to apply specific configurations foreach (WorkBenchServiceType serviceType in _singletonCache.Keys) { IWorkBenchService IWorkBenchService; _singletonCache.TryGetValue(serviceType, out IWorkBenchService); IWorkBenchService.Initialize(); } //prevent from discoveries to run twice or more _isServicesUp = true; }
public static void AddToCache(WorkBenchServiceType singletonType, IWorkBenchService singleton) => Workbench.Instance.AddToCache((WorkbenchServiceType)singletonType, (IWorkbenchService)singleton);