Ejemplo n.º 1
0
        private LanguageUpdateReport UpdateLanguage(Language newLanguage)
        {
            var report = new LanguageUpdateReport();

            report.Language = newLanguage;
            Language existingLanguage = this.allLanguages.FirstOrDefault((l) => l.Key == newLanguage.Key);

            if (existingLanguage == null)
            {
                report.Result = LanguageUpdateReport.UpdateResult.Added;
                this.SaveLanguageToDisk(newLanguage);
            }
            else if (newLanguage.Version > existingLanguage.Version)
            {
                report.Result          = LanguageUpdateReport.UpdateResult.Updated;
                report.PreviousVersion = existingLanguage.Version;
                report.NewVersion      = newLanguage.Version;
                this.SaveLanguageToDisk(newLanguage);
            }
            else
            {
                report.Result = LanguageUpdateReport.UpdateResult.NoChange;
            }

            // newLanguage is a new language instance, even if it's the same "language", so
            // we need to update the reference for the CurrentLanguage to the new one.
            // Note this is not really "changing languages" so we don't fire the callback or update PrefKey
            if (this.CurrentLanguage.Key == newLanguage.Key)
            {
                this.currentLanguage = newLanguage;
            }

            return(report);
        }
        private LanguageUpdateReport UpdateLanguage(Language newLanguage)
        {
            var report = new LanguageUpdateReport();

            report.Language = newLanguage;
            Language existingLanguage = this.GetLanguageByKey(newLanguage.Key);

            if (existingLanguage == null)
            {
                report.Result = LanguageUpdateReport.UpdateResult.Added;
                this.SaveLanguageToDisk(newLanguage);
            }
            else if (newLanguage.Version > existingLanguage.Version)
            {
                report.Result          = LanguageUpdateReport.UpdateResult.Updated;
                report.PreviousVersion = existingLanguage.Version;
                report.NewVersion      = newLanguage.Version;
                this.SaveLanguageToDisk(newLanguage);
            }
            else
            {
                report.Result = LanguageUpdateReport.UpdateResult.NoChange;
            }

            return(report);
        }