/// <inheriteddoc /> public IEnumerable <object> GetAllInstances(Type serviceType, object key = null) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } IEnumerable <object> result = null; ServiceActivationException exceptionToThrow = null; try { result = this.OnGetAllInstances(serviceType, key); if (result == null) { exceptionToThrow = new ServiceActivationException(serviceType, key); } } catch (Exception ex) { exceptionToThrow = new ServiceActivationException(serviceType, key, ex); } if (exceptionToThrow != null) { throw exceptionToThrow; } using (var e = result.GetEnumerator()) { while (e.MoveNext()) { var obj = e.Current; if (obj != null) { yield return(obj); } } } }
/// <inheriteddoc /> public object GetInstance(Type serviceType, object key = null) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } object result = null; ServiceActivationException exceptionToThrow = null; try { result = this.OnGetInstance(serviceType, key); if (result == null) { exceptionToThrow = new ServiceActivationException(serviceType, key); } } catch (Exception ex) { exceptionToThrow = ex as ServiceActivationException; if (exceptionToThrow == null) { exceptionToThrow = new ServiceActivationException(serviceType, key, ex); } } if (exceptionToThrow != null) { throw exceptionToThrow; } return(result); }