Esempio n. 1
0
        public ConfigService(LiteDatabase globalDatabase, LiteDatabase userDatabase)
        {
            var defaultGlobalSettings = new AppConfiguration()
            {
                Id = "v0.18.0",
                OutdatedPackagesCacheDurationInMinutes = "60",
                UseKeyboardBindings              = true,
                DefaultToTileViewForLocalSource  = true,
                DefaultToTileViewForRemoteSource = true
            };

            var defaultUserSettings = new AppConfiguration()
            {
                Id = "v0.18.0"
            };

            // If the global database is null, the assumption has to be that we are running as a non-administrator
            // user, as such, we should proceed with default settings
            if (globalDatabase == null)
            {
                GlobalCollection       = null;
                GlobalAppConfiguration = defaultGlobalSettings;
            }
            else
            {
                GlobalCollection       = globalDatabase.GetCollection <AppConfiguration>(nameof(AppConfiguration));
                GlobalAppConfiguration = GlobalCollection.FindById("v0.18.0") ?? defaultGlobalSettings;
            }

            UserCollection       = userDatabase.GetCollection <AppConfiguration>(nameof(AppConfiguration));
            UserAppConfiguration = UserCollection.FindById("v0.18.0") ?? defaultUserSettings;
        }
        public ConfigService(LiteDatabase globalDatabase, LiteDatabase userDatabase)
        {
            GlobalCollection = globalDatabase.GetCollection <AppConfiguration>(nameof(AppConfiguration));
            UserCollection   = userDatabase.GetCollection <AppConfiguration>(nameof(AppConfiguration));

            var defaultGlobalSettings = new AppConfiguration()
            {
                Id = "v0.18.0",
                OutdatedPackagesCacheDurationInMinutes = "60",
                UseKeyboardBindings              = true,
                DefaultToTileViewForLocalSource  = true,
                DefaultToTileViewForRemoteSource = true
            };

            var defaultUserSettings = new AppConfiguration()
            {
                Id = "v0.18.0"
            };

            GlobalAppConfiguration = GlobalCollection.FindById("v0.18.0") ?? defaultGlobalSettings;
            UserAppConfiguration   = UserCollection.FindById("v0.18.0") ?? defaultUserSettings;
        }