Пример #1
0
        public static Settings Load(Hashtable settings)
        {
            var result = new Settings();

            if (settings == null)
                return result;

            if (settings.Contains("RepoOwner"))
                result.RepoOwner = settings["RepoOwner"].ToString();

            if (settings.Contains("RepoName"))
                result.RepoName = settings["RepoName"].ToString();

            ReleaseTypes releaseType;

            result.ReleaseType = settings.Contains("Releases") && Enum.TryParse(settings["Releases"].ToString(), out releaseType)
                                ? releaseType
                                : ReleaseTypes.Latest;

            result.PreReleaseType = settings.Contains("PreReleases") && Enum.TryParse(settings["PreReleases"].ToString(), out releaseType)
                                ? releaseType
                                : ReleaseTypes.Latest;

            bool boolVal;

            result.EnableDownloadCounts = !settings.Contains("EnableDownloadCount") || !bool.TryParse(settings["EnableDownloadCount"].ToString(), out boolVal) || boolVal;

            return result;
        }
Пример #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpdateSettings saves the modified settings to the Database
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void UpdateSettings()
        {
            try
            {
                ReleaseTypes releaseType;

                var settings = new Components.Settings
                                   {
                                       RepoOwner = txtRepoOwner.Text,
                                       RepoName = txtRepoName.Text,
                                       ReleaseType =
                                           Enum.TryParse(rbRelease.SelectedValue, out releaseType)
                                               ? releaseType
                                               : ReleaseTypes.Latest,
                                       PreReleaseType =
                                           Enum.TryParse(rbPreRelease.SelectedValue, out releaseType)
                                               ? releaseType
                                               : ReleaseTypes.Latest,
                                       EnableDownloadCounts = ckEnableDownloadCount.Checked,
                                   };

                settings.Save(TabModuleId);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }