Exemplo n.º 1
0
 public T GetServiceWithKey <T>(string key)
 {
     if (KeyRegisteredServices.ContainsKey(key))
     {
         return((T)KeyRegisteredServices[key]);
     }
     throw new KeyNotFoundException();
 }
Exemplo n.º 2
0
 public bool RegisterServiceObjectWithKey <T>(T service, string key, bool overwriteIfExists = false)
 {
     lock (KeyRegisteredServices)
     {
         if (!KeyRegisteredServices.ContainsKey(key))
         {
             KeyRegisteredServices.Add(key, service);
             return(true);
         }
         else if (overwriteIfExists)
         {
             KeyRegisteredServices[key] = service;
             return(true);
         }
         return(false);
     }
 }