public void LoadExtraResource(string rpLanguageName) { var rInfo = LoadExtraResourceInfo(rpLanguageName) ?? LoadExtraResourceInfo(GetDefaultLanguage().DisplayName); if (rInfo == null) { Extra = null; OnPropertyChanged(nameof(Extra)); return; } var rESR = new ExtraStringResources(); foreach (var rContent in rInfo.Contents) { if (!rContent.File.Exists) continue; using (var rReader = new JsonTextReader(rContent.File.OpenText())) { var rTranslations = JArray.Load(rReader); if (rContent.Type == ExtraStringResourceType.AbyssalShip) { rESR.AbyssalShip = rTranslations .SelectMany(r => r["id"], (rpTranslation, rpID) => new { ID = (int)rpID, Name = (string)rpTranslation["name"] }) .ToHybridDictionary(r => r.ID, r => r.Name); } else { var rNames = rTranslations.ToHybridDictionary(r => (int)r["id"], r => (string)r["name"]); switch (rContent.Type) { case ExtraStringResourceType.Ship: rESR.Ships = rNames; break; case ExtraStringResourceType.ShipType: rESR.ShipTypes = rNames; break; case ExtraStringResourceType.Equipment: rESR.Equipment = rNames; break; case ExtraStringResourceType.Item: rESR.Items = rNames; break; case ExtraStringResourceType.Expedition: rESR.Expeditions = rNames; break; case ExtraStringResourceType.Quest: rESR.Quests = rNames; break; case ExtraStringResourceType.Area: rESR.Areas = rNames; break; case ExtraStringResourceType.Map: rESR.Maps = rNames; break; case ExtraStringResourceType.ShipLocking: rESR.ShipLocking = rNames; break; } } } } Extra = rESR; OnPropertyChanged(nameof(Extra)); }
public void LoadExtraResource(string rpLanguageName) { var rInfo = LoadExtraResourceInfo(rpLanguageName) ?? LoadExtraResourceInfo(GetDefaultLanguage().DisplayName); if (rInfo == null) { Extra = null; OnPropertyChanged(nameof(Extra)); return; } var rESR = new ExtraStringResources(); foreach (var rContent in rInfo.Contents) { if (!rContent.File.Exists) { continue; } using (var rReader = new JsonTextReader(rContent.File.OpenText())) { var rTranslations = JArray.Load(rReader); if (rContent.Type == ExtraStringResourceType.AbyssalShip) { rESR.AbyssalShip = rTranslations .SelectMany(r => r["id"], (rpTranslation, rpID) => new { ID = (int)rpID, Name = (string)rpTranslation["name"] }) .ToHybridDictionary(r => r.ID, r => r.Name); } else { var rNames = rTranslations.ToHybridDictionary(r => (int)r["id"], r => (string)r["name"]); switch (rContent.Type) { case ExtraStringResourceType.Ship: rESR.Ships = rNames; break; case ExtraStringResourceType.ShipType: rESR.ShipTypes = rNames; break; case ExtraStringResourceType.Equipment: rESR.Equipment = rNames; break; case ExtraStringResourceType.Furniture: rESR.Furnitures = rNames; break; case ExtraStringResourceType.Item: rESR.Items = rNames; break; case ExtraStringResourceType.Expedition: rESR.Expeditions = rNames; break; case ExtraStringResourceType.Quest: rESR.Quests = rNames; break; case ExtraStringResourceType.QuestDescription: rESR.QuestDescriptions = rNames; break; case ExtraStringResourceType.Area: rESR.Areas = rNames; break; case ExtraStringResourceType.Map: rESR.Maps = rNames; break; case ExtraStringResourceType.ShipLocking: rESR.ShipLocking = rNames; break; } } } } Extra = rESR; OnPropertyChanged(nameof(Extra)); }