From 320fc26a2a45fcf38e2dfede8f80d111a14e047f Mon Sep 17 00:00:00 2001 From: Greg Edwards Date: Fri, 8 May 2015 19:05:43 -0400 Subject: [PATCH] Expose Pokedex.Species as an IDictionary. --- library/Pokedex/Pokedex.cs | 9 ++++++--- library/Pokedex/Species.cs | 2 +- web/gts/Default.aspx.cs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/library/Pokedex/Pokedex.cs b/library/Pokedex/Pokedex.cs index 7f0f5cb8..917805a2 100644 --- a/library/Pokedex/Pokedex.cs +++ b/library/Pokedex/Pokedex.cs @@ -172,10 +172,13 @@ namespace PkmnFoundations.Pokedex private Dictionary> m_location_values_generations; - // todo: add ReadOnlyIndexer1d class, replace these methods with them - public Species Species(int national_dex) + // todo: use readonly wrappers + public IDictionary Species { - return m_species[national_dex]; + get + { + return m_species; + } } public Family Families(int id) diff --git a/library/Pokedex/Species.cs b/library/Pokedex/Species.cs index db9a5d17..b6f86649 100644 --- a/library/Pokedex/Species.cs +++ b/library/Pokedex/Species.cs @@ -90,7 +90,7 @@ namespace PkmnFoundations.Pokedex // since we want the Pokemon4/5 ctor to succeed regardless of how // broken the underlying data is. return new LazyKeyValuePair( - k => k == 0 ? null : (pokedex == null ? null : pokedex.Species(k)), + k => k == 0 ? null : (pokedex == null ? null : pokedex.Species[k]), v => v == null ? 0 : v.NationalDex); } } diff --git a/web/gts/Default.aspx.cs b/web/gts/Default.aspx.cs index 853c00d4..b23498a0 100644 --- a/web/gts/Default.aspx.cs +++ b/web/gts/Default.aspx.cs @@ -142,7 +142,7 @@ namespace PkmnFoundations.GTS { Pokedex.Pokedex pokedex = AppStateHelper.Pokedex(Application); GtsRecordBase record = (GtsRecordBase)DataItem; - return Common.HtmlEncode(pokedex.Species(record.Species).Name.ToString()); + return Common.HtmlEncode(pokedex.Species[record.Species].Name.ToString()); } catch { @@ -216,7 +216,7 @@ namespace PkmnFoundations.GTS { Pokedex.Pokedex pokedex = AppStateHelper.Pokedex(Application); GtsRecordBase record = (GtsRecordBase)DataItem; - Species species = pokedex.Species(record.RequestedSpecies); + Species species = pokedex.Species[record.RequestedSpecies]; return "