/// <summary> /// Creates/initializes common infrastructure objects [Configuration, Logging, AppSetting] that are not previously added to <see cref="IServiceCollection" />. /// <remarks> /// Note: the objects [Configuration, Logging, AppSetting] will only be created/initialized if not added in: /// - ConfigureCoreServices /// - CoreServices /// - ConfigureServices /// </remarks> /// </summary> /// <param name="serviceProvider">The <see cref="IServiceProvider"/> for application services.</param> /// <exception cref="Exception"></exception> public virtual void Initialize(IServiceProvider serviceProvider) { if (!_servicesConfigured || !_coreServicesConfigured || !_resolversConfigured || !_defaultHandlersConfigured) { throw new Exception("Services must be configured before application is initialized."); } #region Configuration var config = serviceProvider.GetService <IChromelyConfiguration>(); if (config is null) { config = DefaultConfiguration.CreateForRuntimePlatform(); } ChromelyApp.InitConfiguration(config); #endregion Configuration #region Application/User Settings var appSettings = serviceProvider.GetService <IChromelyAppSettings>(); if (appSettings is null) { appSettings = new DefaultAppSettings(); } var currentAppSettings = new CurrentAppSettings { Properties = appSettings }; ChromelyAppUser.App = currentAppSettings; ChromelyAppUser.App.Properties.Read(config); #endregion #region Logger var logger = GetCurrentLogger(serviceProvider); if (logger is null) { logger = new SimpleLogger(); } var defaultLogger = new DefaultLogger { Log = logger }; Logger.Instance = defaultLogger; #endregion EnsureExpectedWorkingDirectory(); _servicesInitialized = true; }
/// <summary> /// Checks if the application is of OWIN type. /// </summary> /// <param name="app"></param> /// <returns>true if of OWIN type, otherwise false.</returns> public static bool IsOwinApp(this ChromelyApp app) { return(typeof(IOwinAppStartup).IsAssignableFrom(app.GetType())); }