OLD | NEW |
| (Empty) |
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
4 using System.Runtime.InteropServices; | |
5 using System.Text; | |
6 | |
7 namespace Google.MsAd7.BaseImpl | |
8 { | |
9 public class ComUtils | |
10 { | |
11 public static Guid GuidOf(Type t) { | |
12 Guid result = Guid.Empty; | |
13 | |
14 object[] attrs = t.GetCustomAttributes(typeof (InheritGuidAttribute), | |
15 false); | |
16 if(attrs.Length > 0) { | |
17 result = GuidOf(((InheritGuidAttribute) attrs[0]).InheritFrom); | |
18 } | |
19 | |
20 attrs = t.GetCustomAttributes(typeof (GuidAttribute),false); | |
21 if (attrs.Length > 0) { | |
22 result = new Guid(((GuidAttribute) attrs[0]).Value); | |
23 } | |
24 return result; | |
25 } | |
26 | |
27 public static Guid GuidOf(object o) { | |
28 return GuidOf(o.GetType()); | |
29 } | |
30 | |
31 public static void RequireOk(int hr) { | |
32 if (hr != 0) { | |
33 throw new COMException("Error", hr); | |
34 } | |
35 } | |
36 } | |
37 | |
38 public class InheritGuidAttribute : Attribute { | |
39 public InheritGuidAttribute(Type inheritFrom) { | |
40 InheritFrom = inheritFrom; | |
41 } | |
42 | |
43 public Type InheritFrom { get; set; } | |
44 } | |
45 | |
46 | |
47 } | |
OLD | NEW |