Beispiel #1
0
        public void Load(AppSettings settings)
        {
            __IsLoading = true;
            try
            {
                RegisterDefaults();

                foreach (var propertyName in __Defaults.Keys)
                {
                    LoadProperty(settings, propertyName.ToString());
                }

                try
                {
                    settings.RunOnLogin = LoginItems.IsLoginItemInstalled();
                }
                catch (Exception ex)
                {
                    settings.RunOnLogin = false;
                    Logging.Info($"ERROR loading 'RunOnLogin' settings: {ex}");
                }

                LoadCredentials(settings);

                Save(settings);
            }
            finally
            {
                __IsLoading = false;
            }
        }
 private static void SaveLoginItem(bool RunOnLogin)
 {
     if (RunOnLogin)
     {
         LoginItems.AddLoginItem();
     }
     else
     {
         LoginItems.RemoveLoginItem();
     }
 }
Beispiel #3
0
        public void Load(AppSettings settings)
        {
            Exception firstExp = null;

            __IsLoading = true;
            try
            {
                RegisterDefaults();

                foreach (var propertyName in __Defaults.Keys)
                {
                    try
                    {
                        LoadProperty(settings, propertyName.ToString());
                    }
                    catch (Exception e)
                    {
                        // Save first exception but keep loading other properties
                        if (firstExp == null)
                        {
                            firstExp = new Exception($"Failed to load property '{propertyName}'", e);
                        }
                    }
                }

                try
                {
                    settings.RunOnLogin = LoginItems.IsLoginItemInstalled();
                }
                catch (Exception ex)
                {
                    settings.RunOnLogin = false;
                    Logging.Info($"ERROR loading 'RunOnLogin' settings: {ex}");
                }

                LoadCredentials(settings);

                Save(settings);

                if (firstExp != null)
                {
                    throw firstExp;
                }
            }
            finally
            {
                __IsLoading = false;
            }
        }