71
71
private static RuntimeFramework currentFramework;
73
private static Version[] knownVersions = new Version[] {
74
new Version(1, 0, 3705),
75
new Version(1, 1, 4322),
76
new Version(2, 0, 50727),
77
new Version(4, 0, 30319)
80
73
private RuntimeType runtime;
81
74
private Version frameworkVersion;
82
75
private Version clrVersion;
86
79
#region Constructor
89
/// Construct from a runtime type and version
82
/// Construct from a runtime type and version. If the version has
83
/// two parts, it is taken as a framework version. If it has three
84
/// or more, it is taken as a CLR version. In either case, the other
85
/// version is deduced based on the runtime type and provided version.
91
87
/// <param name="runtime">The runtime type of the framework</param>
92
88
/// <param name="version">The version of the framework</param>
95
91
this.runtime = runtime;
93
this.frameworkVersion = runtime == RuntimeType.Mono && version.Major == 1
95
: new Version(version.Major, version.Minor);
96
this.clrVersion = version;
97
98
if (version.Build < 0)
98
InitFromFrameworkVersion(version);
100
InitFromClrVersion(version);
99
this.clrVersion = GetClrVersion(runtime, version);
102
if (version.Major == 3)
103
this.clrVersion = new Version(2, 0, 50727);
104
101
this.displayName = GetDefaultDisplayName(runtime, version);
107
private void InitFromFrameworkVersion(Version version)
104
private static Version GetClrVersion(RuntimeType runtime, Version version)
109
this.frameworkVersion = this.clrVersion = version;
110
foreach (Version v in knownVersions)
111
if (v.Major == version.Major && v.Minor == version.Minor)
117
if (this.runtime == RuntimeType.Mono && version.Major == 1)
119
this.frameworkVersion = new Version(1, 0);
120
this.clrVersion = new Version(1, 1, 4322);
108
case RuntimeType.Silverlight:
109
return version.Major >= 4
110
? new Version(4, 0, 60310)
111
: new Version(2, 0, 50727);
114
switch (version.Major)
117
return new Version(4, 0, 30319);
121
return new Version(2, 0, 50727);
124
return version.Minor == 0 && runtime != RuntimeType.Mono
125
? new Version(1, 0, 3705)
126
: new Version(1, 1, 4322);
124
private void InitFromClrVersion(Version version)
126
this.frameworkVersion = new Version(version.Major, version.Minor);
127
this.clrVersion = version;
128
if (runtime == RuntimeType.Mono && version.Major == 1)
129
this.frameworkVersion = new Version(1, 0);
134
136
#region Properties
143
145
if (currentFramework == null)
146
RuntimeType runtime = RuntimeType.Silverlight;
148
currentFramework = new RuntimeFramework(
149
RuntimeType.Silverlight,
150
new Version(Environment.Version.Major, Environment.Version.Minor));
150
152
Type monoRuntimeType = Type.GetType("Mono.Runtime", false);
151
153
Type monoTouchType = Type.GetType("MonoTouch.UIKit.UIApplicationDelegate, monotouch");
414
414
if (this.AllowAnyVersion || target.AllowAnyVersion)
417
return VersionsMatch(this.ClrVersion, target.ClrVersion)
418
&& this.FrameworkVersion.Major >= target.FrameworkVersion.Major
419
&& this.FrameworkVersion.Minor >= target.FrameworkVersion.Minor;
417
if (!VersionsMatch(this.ClrVersion, target.ClrVersion))
420
return Runtime == RuntimeType.Silverlight
421
? this.frameworkVersion.Major == target.FrameworkVersion.Major && this.frameworkVersion.Minor == target.FrameworkVersion.Minor
422
: this.FrameworkVersion.Major >= target.FrameworkVersion.Major && this.FrameworkVersion.Minor >= target.FrameworkVersion.Minor;