/// <exception cref="ArgumentException"><see cref="Verify" /> is not called.</exception> /// <exception cref="MemoryInjectionException">If the object has been changed after last stamp.</exception> /// <exception cref="MemoryInjectionException">If the object has been changed after last stamp.</exception> /// <exception cref="KeyNotFoundException">If the <paramref name="serviceType" /> is not registered.</exception> public object GetService(Type serviceType) { if (!_isVerified) { throw new ArgumentException($"Please call {nameof(Verify)} before using the factory"); } SpinUntilSecurityModeIsAvailable(); var key = _typeIdGenerator.Generate(serviceType); IInstanceProvider instanceProvider; var success = _typeInstancesSafe.Object.TryGetValue(key, out instanceProvider); if (!success) { throw new KeyNotFoundException($"{serviceType.FullName} is not registered."); } var result = instanceProvider.Provide(); return(result); }
private string GetCodeId(Type type) => _typeIdGenerator.Generate(type);