mscorlib(4.0.0.0) API with additions
WindowsRuntimeMetadata.cs
3 using System.Reflection;
5 using System.Security;
6 
8 {
10  public static class WindowsRuntimeMetadata
11  {
13  [method: SecurityCritical]
14  public static event EventHandler<NamespaceResolveEventArgs> ReflectionOnlyNamespaceResolve;
15 
17  [method: SecurityCritical]
18  public static event EventHandler<DesignerNamespaceResolveEventArgs> DesignerNamespaceResolve;
19 
27  [SecurityCritical]
28  public static IEnumerable<string> ResolveNamespace(string namespaceName, IEnumerable<string> packageGraphFilePaths)
29  {
30  return ResolveNamespace(namespaceName, null, packageGraphFilePaths);
31  }
32 
41  [SecurityCritical]
42  public static IEnumerable<string> ResolveNamespace(string namespaceName, string windowsSdkFilePath, IEnumerable<string> packageGraphFilePaths)
43  {
44  if (namespaceName == null)
45  {
46  throw new ArgumentNullException("namespaceName");
47  }
48  string[] array = null;
49  if (packageGraphFilePaths != null)
50  {
51  List<string> list = new List<string>(packageGraphFilePaths);
52  array = new string[list.Count];
53  int num = 0;
54  foreach (string item in list)
55  {
56  string text = array[num] = item;
57  num++;
58  }
59  }
60  string[] o = null;
61  nResolveNamespace(namespaceName, windowsSdkFilePath, array, (array != null) ? array.Length : 0, JitHelpers.GetObjectHandleOnStack(ref o));
62  return o;
63  }
64 
65  [DllImport("QCall", CharSet = CharSet.Unicode)]
66  [SecurityCritical]
67  [SuppressUnmanagedCodeSecurity]
68  private static extern void nResolveNamespace(string namespaceName, string windowsSdkFilePath, string[] packageGraphFilePaths, int cPackageGraphFilePaths, ObjectHandleOnStack retFileNames);
69 
70  internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
71  {
72  EventHandler<NamespaceResolveEventArgs> reflectionOnlyNamespaceResolve = WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve;
73  if (reflectionOnlyNamespaceResolve != null)
74  {
75  Delegate[] invocationList = reflectionOnlyNamespaceResolve.GetInvocationList();
76  int num = invocationList.Length;
77  for (int i = 0; i < num; i++)
78  {
79  NamespaceResolveEventArgs namespaceResolveEventArgs = new NamespaceResolveEventArgs(namespaceName, assembly);
80  ((EventHandler<NamespaceResolveEventArgs>)invocationList[i])(appDomain, namespaceResolveEventArgs);
81  Collection<Assembly> resolvedAssemblies = namespaceResolveEventArgs.ResolvedAssemblies;
82  if (resolvedAssemblies.Count > 0)
83  {
84  RuntimeAssembly[] array = new RuntimeAssembly[resolvedAssemblies.Count];
85  int num2 = 0;
86  {
87  foreach (Assembly item in resolvedAssemblies)
88  {
89  array[num2] = AppDomain.GetRuntimeAssembly(item);
90  num2++;
91  }
92  return array;
93  }
94  }
95  }
96  }
97  return null;
98  }
99 
100  internal static string[] OnDesignerNamespaceResolveEvent(AppDomain appDomain, string namespaceName)
101  {
102  EventHandler<DesignerNamespaceResolveEventArgs> designerNamespaceResolve = WindowsRuntimeMetadata.DesignerNamespaceResolve;
103  if (designerNamespaceResolve != null)
104  {
105  Delegate[] invocationList = designerNamespaceResolve.GetInvocationList();
106  int num = invocationList.Length;
107  for (int i = 0; i < num; i++)
108  {
109  DesignerNamespaceResolveEventArgs designerNamespaceResolveEventArgs = new DesignerNamespaceResolveEventArgs(namespaceName);
110  ((EventHandler<DesignerNamespaceResolveEventArgs>)invocationList[i])(appDomain, designerNamespaceResolveEventArgs);
111  Collection<string> resolvedAssemblyFiles = designerNamespaceResolveEventArgs.ResolvedAssemblyFiles;
112  if (resolvedAssemblyFiles.Count > 0)
113  {
114  string[] array = new string[resolvedAssemblyFiles.Count];
115  int num2 = 0;
116  {
117  foreach (string item in resolvedAssemblyFiles)
118  {
119  if (string.IsNullOrEmpty(item))
120  {
121  throw new ArgumentException(Environment.GetResourceString("Arg_EmptyOrNullString"), "DesignerNamespaceResolveEventArgs.ResolvedAssemblyFiles");
122  }
123  array[num2] = item;
124  num2++;
125  }
126  return array;
127  }
128  }
129  }
130  }
131  return null;
132  }
133  }
134 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Definition: __Canon.cs:3
virtual Delegate [] GetInvocationList()
Returns the invocation list of the delegate.
Definition: Delegate.cs:234
Represents an application domain, which is an isolated environment where applications execute....
Definition: AppDomain.cs:33
Provides an event for resolving reflection-only type requests for types that are provided by Windows ...
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Definition: Assembly.cs:22
static EventHandler< NamespaceResolveEventArgs > ReflectionOnlyNamespaceResolve
Occurs when the resolution of a Windows Metadata file fails in the reflection-only context.
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition: Delegate.cs:15
int Count
Gets the number of elements actually contained in the T:System.Collections.ObjectModel....
Definition: Collection.cs:26
static EventHandler< DesignerNamespaceResolveEventArgs > DesignerNamespaceResolve
Occurs when the resolution of a Windows Metadata file fails in the design environment.
CharSet
Dictates which character set marshaled strings should use.
Definition: CharSet.cs:7
Collection< Assembly > ResolvedAssemblies
Gets a collection of assemblies; when the event handler for the E:System.Runtime.InteropServices....
static IEnumerable< string > ResolveNamespace(string namespaceName, string windowsSdkFilePath, IEnumerable< string > packageGraphFilePaths)
Locates the Windows Metadata files for the specified namespace, given the specified locations to sear...
static IEnumerable< string > ResolveNamespace(string namespaceName, IEnumerable< string > packageGraphFilePaths)
Locates the Windows Metadata files for the specified namespace, given the specified locations to sear...
Attribute can be applied to a delegate.
Provides data for the E:System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMetadata....