private static void RegisterCommonServices(this IServiceCollection services, ServiceConfiguration config, IEnvironmentSettings env) { if (services == null) { throw new ArgumentNullException(nameof(services)); } // Request items services.TryAddScoped <IHttpData, HttpData.HttpData>(); services.TryAddScoped <IRequestData, RequestData.RequestData>(); // Authorization services.TryAddScoped <IIdentityHelper, IdentityHelper <BasicIdentity> >(); // Caching services.AddMemoryCache(); services.TryAddTransient <DefaultCacheOptions, DefaultCacheOptions>(); var url = config.CacheRedisUrl(env); if (!string.IsNullOrWhiteSpace(url)) { services.AddStackExchangeRedisCache(options => { options.Configuration = url; }); services.TryAddTransient <ICache, CacheLocalAndDistributed>(); } else { services.TryAddTransient <ICache, CacheLocal>(); } // Email services.TryAddTransient <IEmail, EmailMock>(); // Encryption services.TryAddTransient <IEncryption, EncryptionDispatcher>(); services.TryAddTransient <IEncryptionAlgorithms, SphyrnidaeEncryptionAlgorithms>(); services.TryAddTransient <IEncryptionKeyManager, EncryptionKeyManager>(); // Feature Toggle services.TryAddTransient <IFeatureToggleSettings, FeatureToggleSettingsDefault>(); services.TryAddTransient <IFeatureToggleServices, FeatureToggleServices>(); // Logging services.TryAddTransient <ILogger, Logger>(); services.TryAddScoped <ILoggerConfiguration, MockLoggerConfiguration>(); services.TryAddTransient <ILoggerInformation, LoggerInformation>(); services.TryAddTransient <ILoggers, LoggersNone>(); services.TryAddTransient <IAlert, Alert>(); services.TryAddTransient <ApiInformation, ApiInformation>(); services.TryAddTransient <AttributeInformation, AttributeInformation>(); //services.TryAddTransient<CustomInformation1, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use //services.TryAddTransient<CustomInformation2, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use //services.TryAddTransient<CustomInformation3, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use //services.TryAddTransient<CustomTimerInformation1, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use //services.TryAddTransient<CustomTimerInformation2, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use //services.TryAddTransient<CustomTimerInformation3, YOUR_CUSTOM_CLASS>(); // Will need to specify implementation if you wish to use services.TryAddTransient <DatabaseInformation, DatabaseInformation>(); services.TryAddTransient <ExceptionInformation, ExceptionInformation>(); services.TryAddTransient <HttpResponseInformation, HttpResponseInformation>(); services.TryAddTransient <LongRunningInformation, LongRunningInformation>(); services.TryAddTransient <MessageInformation, MessageInformation>(); services.TryAddTransient <MiddlewareInformation, MiddlewareInformation>(); services.TryAddTransient <TimerInformation, TimerInformation>(); services.TryAddTransient <UnauthorizedInformation, UnauthorizedInformation>(); services.TryAddTransient <WebServiceInformation, WebServiceInformation>(); // User Preferences services.TryAddTransient <IUserPreferenceSettings, UserPreferenceSettingsDefault>(); services.TryAddTransient <IUserPreferenceServices, UserPreferenceServices>(); // Variables services.TryAddTransient <IVariableSettings, VariableSettingsDefault>(); services.TryAddTransient <IVariableServices, VariableServices>(); // Web Services services.TryAddTransient <IApiAuthenticationWebService, ApiAuthenticationWebServiceMock>(); // Transient Helpers //services.TryAddTransient<IApplicationSettings, YOUR_APP_SETTINGS_CLASS>(); // Caller must do this services.TryAddTransient <IEnvironmentSettings, EnvironmentalSettings>(); services.TryAddTransient <IHttpClientSettings, HttpClientSettings>(); services.TryAddTransient <ISignalR, SignalR.SignalR>(); services.TryAddTransient <IApiResponse, ApiResponseStandard>(); }