示例#1
0
 public T GetService <T>()
 {
     if (InitialisedServices.ContainsKey(typeof(T)))
     {
         return((T)InitialisedServices[typeof(T)]);
     }
     throw new KeyNotFoundException();
 }
示例#2
0
 public bool RegisterServiceObject <T>(T service, bool overwriteIfExists = false)
 {
     lock (InitialisedServices)
     {
         if (!InitialisedServices.ContainsKey(typeof(T)))
         {
             InitialisedServices.Add(typeof(T), service);
             return(true);
         }
         else if (overwriteIfExists)
         {
             InitialisedServices[typeof(T)] = service;
             return(true);
         }
         return(false);
     }
 }