@@ -28,16 +28,19 @@ public class PlatformData
2828
2929 public static string ResolveFlashPlayerVersion ( string otherPlatform , string version )
3030 {
31- var otherTarget = PluginCore . PlatformData . PlatformTargets [ otherPlatform ] ;
3231 var flashTarget = PluginCore . PlatformData . PlatformTargets [ "Flash Player" ] ;
33- foreach ( var otherVersion in otherTarget . Versions )
34- if ( otherVersion . Value == version )
35- {
36- foreach ( var flashVersion in flashTarget . Versions )
37- if ( flashVersion . SwfVersion == otherVersion . SwfVersion ) return flashVersion . Value ;
38- }
39- // default to last
40- return flashTarget . Versions [ flashTarget . Versions . Count - 1 ] . Value ;
32+ if ( PlatformTargets . ContainsKey ( otherPlatform ) )
33+ {
34+ var otherTarget = PluginCore . PlatformData . PlatformTargets [ otherPlatform ] ;
35+ foreach ( var otherVersion in otherTarget . Versions )
36+ if ( otherVersion . Value == version )
37+ {
38+ foreach ( var flashVersion in flashTarget . Versions )
39+ if ( flashVersion . SwfVersion == otherVersion . SwfVersion ) return flashVersion . Value ;
40+ }
41+ }
42+ // default to last FP
43+ return flashTarget . LastVersion . Value ;
4144 }
4245
4346 public static string ResolveSwfVersion ( string platformName , string version )
@@ -46,7 +49,8 @@ public static string ResolveSwfVersion(string platformName, string version)
4649 foreach ( var platformVersion in platform . Versions )
4750 if ( platformVersion . Value == version )
4851 return platformVersion . SwfVersion ;
49- return platform . Versions [ platform . Versions . Count - 1 ] . SwfVersion ;
52+ // default to last FP
53+ return platform . LastVersion . SwfVersion ;
5054 }
5155
5256 #region platform config loading
@@ -81,13 +85,11 @@ private static void ParseLanguages(XmlNode languages)
8185 PlatformLanguages = new Dictionary < String , PlatformLanguage > ( ) ;
8286 if ( PlatformTargets == null || PlatformTargets . Count == 0 )
8387 {
88+ var defaultVersion = new PlatformVersion { Value = "0.0" } ;
8489 var custom = new PlatformTarget {
8590 Name = "Custom" ,
86- Versions = new List < PlatformVersion > {
87- new PlatformVersion {
88- Value = "0.0"
89- }
90- }
91+ Versions = new List < PlatformVersion > { defaultVersion } ,
92+ LastVersion = defaultVersion
9193 } ;
9294 PlatformTargets . Add ( custom . Name , custom ) ;
9395 return ;
@@ -192,10 +194,12 @@ private static void ParsePlatforms(XmlNode platforms)
192194 PlatformTargets = new Dictionary < String , PlatformTarget > ( ) ;
193195 foreach ( XmlNode node in platforms . ChildNodes )
194196 {
197+ var versions = ParseVersions ( node ) ;
195198 var target = new PlatformTarget
196199 {
197200 Name = node . Attributes [ "name" ] . Value ,
198- Versions = ParseVersions ( node ) ,
201+ Versions = versions ,
202+ LastVersion = versions [ versions . Count - 1 ] ,
199203 RawData = node
200204 } ;
201205 PlatformTargets . Add ( target . Name , target ) ;
@@ -216,6 +220,7 @@ public class PlatformTarget
216220 {
217221 public string Name ;
218222 public List < PlatformVersion > Versions ;
223+ public PlatformVersion LastVersion ;
219224 public XmlNode RawData ;
220225 }
221226
0 commit comments