예제 #1
0
        // NOTE: For some reason we have to create _new_ objects - not just reference to the model - for the settings to be stored!??!!?
        public static void Save(NZBDriveModel model)
        {
            NZBDriveSettingsData settings = new NZBDriveSettingsData()
            {
                UsenetServers = model.NewsServerCollection.Select(server => new NewsServerConnectionData(server.ServerConnection)).ToList(),
                Throttling    = new NewsServerThrottlingData(model.NewsServerThrottling),
                LatestVersion = model.LatestVersion != null?model.LatestVersion.ToString() : "",
                                    LatestVersionCheckDate = model.LatestVersionCheckDate,
                                    Options = new NZBDriveOptionsData(model.Options)
            };

            settings.Save();
        }
예제 #2
0
        public static void Load(NZBDriveModel model)
        {
            NZBDriveSettingsData settings = new NZBDriveSettingsData();

            settings.Reload();

            if (settings.LicenseKey != null)
            {
                model.LicenseKey = settings.LicenseKey;
            }

            if (settings.Options != null)
            {
                model.Options.SetValues(settings.Options);
            }

            model.StartDrive();

            if (settings.UsenetServers != null)
            {
                foreach (var server in settings.UsenetServers)
                {
                    model.NewsServerCollection.Add(server);
                }
            }
            if (settings.Throttling != null)
            {
                model.NewsServerThrottling.Update(settings.Throttling);
            }

            model.LatestVersion = new Version();
            if (settings.LatestVersion != null)
            {
                try
                {
                    model.LatestVersion = new Version(settings.LatestVersion);
                }
                catch (Exception)
                { }
            }
            if (settings.LatestVersionCheckDate != null)
            {
                model.LatestVersionCheckDate = settings.LatestVersionCheckDate;
            }
        }