/// <summary> /// Global initialization of the app and loads all app settings and initializes all services. /// </summary> /// <param name="mode">Specifies the mode of this app instance and how it's executing.</param> /// <returns>Awaitable task is returned.</returns> public virtual Task AppInitializingAsync(InitializationModes mode) { this.InitializationMode = mode; this.Logger.Log(LogLevels.Warning, "APP INITIALIZING - Initialization mode is {0}", this.InitializationMode); this.AppSettingsLocal = this.Storage.LoadSetting <AppSettingsLocal>("AppSettingsLocal", ApplicationData.Current.LocalSettings) ?? new AppSettingsLocal(); this.AppSettingsLocal.PropertyChanged += AppSettingsLocal_PropertyChanged; this.AppSettingsRoaming = this.Storage.LoadSetting <AppSettingsRoaming>("AppSettingsRoaming", ApplicationData.Current.RoamingSettings) ?? new AppSettingsRoaming(); this.AppSettingsRoaming.PropertyChanged += AppSettingsRoaming_PropertyChanged; // Initializes all service foreach (var service in _services) { this.CheckInitialization(service.Value); } // Execute only on first runs of the platform if (mode == InitializationModes.New) { // Provide platform languages to analytics this.Analytics.Event("CurrentCulture", System.Globalization.CultureInfo.CurrentCulture.Name); this.Analytics.Event("CurrentUICulture", System.Globalization.CultureInfo.CurrentUICulture.Name); } // Register all background agents if (mode != InitializationModes.Background) { var btm = Platform.Current.BackgroundTasks.RegisterAllAsync(); } return(Task.CompletedTask); }
/// <summary> /// Reset all the app settings back to their defaults. /// </summary> protected void ResetAppSettings() { if (this.AppSettingsLocal != null) { this.AppSettingsLocal.PropertyChanged -= AppSettingsLocal_PropertyChanged; } if (this.AppSettingsRoaming != null) { this.AppSettingsRoaming.PropertyChanged -= AppSettingsRoaming_PropertyChanged; } _settingsIsLocalDataDirty = true; _settingsIsRoamingDataDirty = true; this.AppSettingsLocal = new AppSettingsLocal(); this.AppSettingsLocal.PropertyChanged += AppSettingsLocal_PropertyChanged; this.AppSettingsRoaming = new AppSettingsRoaming(); this.AppSettingsRoaming.PropertyChanged += AppSettingsRoaming_PropertyChanged; this.SaveSettings(); }