update tuner
[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         abstract class Profile {
9
10                 static Profile current;
11
12                 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 IsProductAssembly (AssemblyDefinition assembly)
48                 {
49                         return Current.IsProduct (assembly);
50                 }
51
52                 protected abstract bool IsSdk (AssemblyDefinition assembly);
53                 protected abstract bool IsProduct (AssemblyDefinition assembly);
54         }
55 }