Merge back MonoTouch changes inside the linker/tuner code
[mono.git] / mcs / tools / tuner / Mono.Tuner / Profile.cs
1 using System;
2 using System.Collections.Generic;
3
4 using Mono.Cecil;
5
6 namespace Mono.Tuner {
7
8         public abstract class Profile {
9
10                 static Profile current;
11
12                 public static Profile Current {
13                         get {
14                                 if (current != null)
15                                         return current;
16
17                                 current = CreateProfile ("MonoTouch");
18                                 if (current != null)
19                                         return current;
20
21                                 current = CreateProfile ("MonoDroid");
22                                 if (current != null)
23                                         return current;
24
25                                 current = CreateProfile ("MonoMac");
26                                 if (current != null)
27                                         return current;
28
29                                 throw new NotSupportedException ("No active profile");
30                         }
31                 }
32
33                 static Profile CreateProfile (string name)
34                 {
35                         var type = Type.GetType (string.Format ("{0}.Tuner.{0}Profile", name));
36                         if (type == null)
37                                 return null;
38
39                         return (Profile) Activator.CreateInstance (type);
40                 }
41
42                 public static bool IsSdkAssembly (AssemblyDefinition assembly)
43                 {
44                         return Current.IsSdk (assembly);
45                 }
46
47                 public static bool IsSdkAssembly (string assemblyName)
48                 {
49                         return Current.IsSdk (assemblyName);
50                 }
51
52                 public static bool IsProductAssembly (AssemblyDefinition assembly)
53                 {
54                         return Current.IsProduct (assembly);
55                 }
56
57                 public static bool IsProductAssembly (string assemblyName)
58                 {
59                         return Current.IsProduct (assemblyName);
60                 }
61
62                 protected virtual bool IsSdk (AssemblyDefinition assembly)
63                 {
64                         return IsSdk (assembly.Name.Name);
65                 }
66                 
67                 protected virtual bool IsProduct (AssemblyDefinition assembly)
68                 {
69                         return IsProduct (assembly.Name.Name);
70                 }
71
72                 protected abstract bool IsSdk (string assemblyName);
73                 protected abstract bool IsProduct (string assemblyName);
74         }
75 }