public static void Register <T>(string serviceName, T obj) { if (RegisteredServices.ContainsKey(serviceName)) { throw new Exception($"Service {serviceName} has already been registered."); } RegisteredServices.Add(serviceName, obj); }
public static T Resolve <T>(string serviceName, bool dontThrow = false) { if (RegisteredServices.ContainsKey(serviceName)) { return((T)RegisteredServices[serviceName]); } if (dontThrow) { return((T)(object)null); } throw new Exception($"Service {serviceName} is not registered."); }