using FISSDKDemoV2.Database.IRespository; using System; using System.Collections.Generic; namespace FISSDKDemoV2.Manager { internal class DataBaseManager { private static Dictionary _services = new Dictionary(); /// /// Register a service into the container. /// /// /// /// public static void RegisterService(IDatabaseService service) { var type = typeof(T); if (_services.ContainsKey(type)) { throw new InvalidOperationException($"Key:{type.Name} already exists."); } _services.Add(type, service); } /// /// Get the service from the container. /// /// /// /// public static T GetService() { var type = typeof(T); if (_services.ContainsKey(type)) { return (T)_services[type]; } throw new KeyNotFoundException($"Can not find the key:{type.Name}"); } } }