/[RomCheater]/trunk/RomCheater.Core/ProcessorAssemblyArchitecture.cs
ViewVC logotype

Contents of /trunk/RomCheater.Core/ProcessorAssemblyArchitecture.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 119 - (show annotations) (download)
Thu May 10 18:34:26 2012 UTC (8 years, 5 months ago) by william
File size: 2436 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace System.Reflection
7 {
8
9
10 [AttributeUsage(AttributeTargets.Assembly)]
11 public class ProcessorAssemblyArchitecture : Attribute
12 {
13 public ProcessorAssemblyArchitecture() { Architecture = Undefined; }
14 public ProcessorAssemblyArchitecture(string arch)
15 {
16 Type t = typeof(ProcessorAssemblyArchitecture);
17 FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static);
18
19 bool found = false;
20 foreach (FieldInfo field in fields)
21 {
22 string o = field.GetValue(null).ToString();
23 if (arch == o)
24 {
25 found = true;
26 break;
27 }
28 }
29 if (!found) { Architecture = Undefined; }
30 else { Architecture = arch; }
31 }
32 string _Architecture;
33 public string Architecture { get { return _Architecture; } private set { _Architecture = value; } }
34 #region processor architecture
35 public const string Undefined = "Undefined";
36 public const string x86 = "x86";
37 public const string x64 = "x64";
38 public const string Amd64 = "Amd64";
39 public const string Ia64 = "Ia64";
40 public const string AnyCpu = "AnyCpu";
41 public const string Msil = AnyCpu;
42 #endregion
43
44 public static string GetProcessorArchitecture(Assembly t)
45 {
46 string assembly_arch = Undefined;
47
48 // get architecture
49 ProcessorArchitecture o = t.GetName().ProcessorArchitecture;
50 if (o == ProcessorArchitecture.None)
51 assembly_arch = Undefined;
52
53 switch (o)
54 {
55 case ProcessorArchitecture.Amd64: assembly_arch = Amd64; break;
56 case ProcessorArchitecture.IA64: assembly_arch = Ia64; break;
57 case ProcessorArchitecture.MSIL: assembly_arch = AnyCpu; break;
58 case ProcessorArchitecture.X86: assembly_arch = x86; break;
59 case ProcessorArchitecture.None: break;
60 default: assembly_arch = Undefined; break;
61 }
62
63 return assembly_arch;
64 }
65
66 }
67 }
68

  ViewVC Help
Powered by ViewVC 1.1.22