2
// SupportedFramework.cs
4
// Author: Jeffrey Stedfast <jeff@xamarin.com>
6
// Copyright (c) 2012 Xamarin Inc.
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to deal
10
// in the Software without restriction, including without limitation the rights
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
// copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
namespace MonoDevelop.Core.Assemblies
32
public class SupportedFramework
34
public static readonly Version NoMaximumVersion = new Version (int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue);
35
public static readonly Version NoMinumumVersion = new Version (0, 0, 0, 0);
37
public SupportedFramework (TargetFramework target, string identifier, string display, string profile, Version minVersion, string minDisplayVersion)
39
MinimumVersionDisplayName = minDisplayVersion;
40
MinimumVersion = minVersion;
41
MaximumVersion = NoMaximumVersion;
42
DisplayName = display;
43
Identifier = identifier;
46
TargetFramework = target;
49
internal SupportedFramework (TargetFramework target)
51
MinimumVersionDisplayName = string.Empty;
52
MinimumVersion = NoMinumumVersion;
53
MaximumVersion = NoMaximumVersion;
54
DisplayName = string.Empty;
55
Identifier = string.Empty;
56
Profile = string.Empty;
58
TargetFramework = target;
61
public string DisplayName {
65
public string Identifier {
69
public string Profile {
73
public string MinimumVersionDisplayName {
77
public Version MinimumVersion {
81
public Version MaximumVersion {
85
public TargetFramework TargetFramework {
89
static Version ParseVersion (string version, Version wildcard)
94
return Version.Parse (version);
97
internal static SupportedFramework Load (TargetFramework target, FilePath path)
99
SupportedFramework fx = new SupportedFramework (target);
101
fx.DisplayName = path.FileNameWithoutExtension;
103
using (var reader = XmlReader.Create (path)) {
104
if (!reader.ReadToDescendant ("Framework"))
105
throw new Exception ("Missing Framework element");
107
if (!reader.HasAttributes)
108
throw new Exception ("Framework element does not contain any attributes");
110
while (reader.MoveToNextAttribute ()) {
111
switch (reader.Name) {
112
case "MaximumVersion":
113
fx.MaximumVersion = ParseVersion (reader.Value, NoMaximumVersion);
115
case "MinimumVersion":
116
fx.MinimumVersion = ParseVersion (reader.Value, NoMinumumVersion);
119
fx.Profile = reader.Value;
122
fx.Identifier = reader.Value;
124
case "MinimumVersionDisplayName":
125
fx.MinimumVersionDisplayName = reader.Value;
128
fx.DisplayName = reader.Value;
134
if (string.IsNullOrEmpty (fx.Identifier))
135
throw new Exception ("Framework element did not specify an Identifier attribute");