/// <summary>Finds the <see cref="WoWLanguagePack"/>s associated with this <see cref="WoWInstallation"/>.</summary> /// <remarks>Each <see cref="WoWLanguagePack"/> itself contains another list of archives.</remarks> private void FindLanguagePacks() { var languagePackList = new List <WoWLanguagePack>(); foreach (string directoryPath in Directory.GetDirectories(dataPath)) { string directoryName = IOPath.GetFileName(directoryPath); if (directoryName != null && directoryName.Length == 4) { try { // Tries to create a CultureInfo object from th directory name // WoW language packs use standard culture identifiers, meaning this should only fail if an invalid directory is found here CultureInfo culture = new CultureInfo(directoryName.Substring(0, 2) + '-' + directoryName.Substring(2, 2)); // Adds the newly found LanguagePack to the list languagePackList.Add(new WoWLanguagePack(this, culture)); } catch (ArgumentException) { } // Catches only ArgumentException, which should only happen when CultureInfo constructor fails } } languagePackArray = languagePackList.ToArray(); languagePackCollection = new LanguagePackCollection(this); }
/// <summary>Initializes a new instance of the <see cref="WoWInstallation"/> class.</summary> /// <param name="path">The installation path.</param> /// <exception cref="DirectoryNotFoundException"><paramref name="path"/> does not exist, or does not contain a directory named <c>Data</c>.</exception> /// <exception cref="FileNotFoundException">At least one of the required archives has not been found in the specified directory.</exception> private WoWInstallation(string path) { if (!Directory.Exists(this.wowPath = path)) { throw new DirectoryNotFoundException(); } if (!Directory.Exists(this.dataPath = System.IO.Path.Combine(path, "Data"))) { throw new DirectoryNotFoundException(); } var detector = new WoWArchiveDetector(this.dataPath); archiveArray = detector.CollectArchives(); installationKind = detector.DetermineInstallationKind().Value; archiveCollection = new ReadOnlyCollection <WoWArchiveInformation>(archiveArray); languagePackArray = detector.CollectLanguagePacks(this); languagePackCollection = new LanguagePackCollection(this); }