Exemple #1
0
        /// <summary>
        /// Retrieves a collection of locales available to download the help for
        /// </summary>
        /// <returns>
        /// Collection of Locales available
        /// </returns>
        /// <exception cref="WebException">
        /// If the data cannot be downloaded
        /// </exception>
        /// <exception cref="XmlException">
        /// If the data cannot be processed
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// If the data cannot be processed
        /// </exception>
        public ICollection <CatalogLocale> LoadAvailableLocales(Catalog nameCatalog)
        {
            if (nameCatalog == null)
            {
                throw new ArgumentNullException("catalog");
            }

            ICollection <CatalogLocale> result;

            if (string.Empty == nameCatalog.CatalogLink)
            {
                result = new List <CatalogLocale>();
            }
            else
            {
                result = HelpIndexManager.LoadLocales(client.DownloadData(nameCatalog.CatalogLink));
            }

            //List<CatalogLocale> result = new List<CatalogLocale>();

            string[] Names =
            {
                "cs-cz", "de-de", "en-us", "es-es", "fr-fr",
                "it-it", "ja-jp", "ko-kr", "pl-pl", "pt-br",
                "ru-ru", "tr-tr", "zh-cn", "zh-tw"
            };

            if (result.Count < Names.Length)
            {
                result.Clear();
                foreach (string name in Names)
                {
                    result.Add(
                        new CatalogLocale
                    {
                        Locale      = name,
                        CatalogName = nameCatalog.Name,
                        Description = nameCatalog.Name,
                        LocaleLink  = ((string.Empty != nameCatalog.CatalogLink)
                                ? (nameCatalog.CatalogLink + @"/" + name)
                                : (@"../catalogs/" + nameCatalog.Name + @"/" + name))
                    });
                }
            }
            (result as List <CatalogLocale>).Sort();
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Retrieves a collection of locales available to download the help for
        /// </summary>
        /// <returns>
        /// Collection of Locales available
        /// </returns>
        /// <exception cref="WebException">
        /// If the data cannot be downloaded
        /// </exception>
        /// <exception cref="XmlException">
        /// If the data cannot be processed
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// If the data cannot be processed
        /// </exception>
        public ICollection <CatalogLocale> LoadAvailableLocales(Catalog nameCatalog)
        {
            if (nameCatalog == null)
            {
                throw new ArgumentNullException(nameof(nameCatalog));
            }

            var result = string.IsNullOrEmpty(nameCatalog.CatalogLink) ? new List <CatalogLocale>() : HelpIndexManager.LoadLocales(_client.DownloadData(nameCatalog.CatalogLink));

            //List<CatalogLocale> result = new List<CatalogLocale>();

            string[] names =
            {
                "cs-cz", "de-de", "en-us", "es-es", "fr-fr",
                "it-it", "ja-jp", "ko-kr", "pl-pl", "pt-br",
                "ru-ru", "tr-tr", "zh-cn", "zh-tw"
            };

            //if (result.Count < names.Length)
            {
                //result.Clear();
                foreach (string name in names)
                {
                    CatalogLocale cataloglocale = new CatalogLocale
                    {
                        Locale      = name,
                        CatalogName = nameCatalog.Name,
                        Description = nameCatalog.Name,
                        LocaleLink  = (!string.IsNullOrEmpty(nameCatalog.CatalogLink)
                                ? (nameCatalog.CatalogLink + @"/" + name)
                                : (@"../catalogs/" + nameCatalog.Name + @"/" + name))
                    };
                    if (!result.Contains(cataloglocale))
                    {
                        result.Add(cataloglocale);
                    }
                }
            }
            var catalogLocales = result as List <CatalogLocale>;

            catalogLocales?.Sort();
            return(result);
        }