public I GetService <I>() where I : class { Type key = typeof(I); if (!mContainer.ContainsKey(key)) { return(default(I)); } ServiceHolder <I> container = (ServiceHolder <I>)mContainer[key]; return(container.Service); }
private bool RegisterServiceInternal <I>(I instance, Lazy <I> lazyInstance, string serviceName = null) where I : class { if (instance == default(I) && lazyInstance == null) { throw new ArgumentNullException("RegisterService - Cannot be null"); } Type key = typeof(I); if (mContainer.ContainsKey(key)) { return(false); } var container = new ServiceHolder <I>(instance, lazyInstance, serviceName); mContainer.AddOrUpdate(key, container, (k, o) => container); return(true); }