本文整理汇总了C#中System.Type.GetNestedType方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetNestedType方法的具体用法?C# Type.GetNestedType怎么用?C# Type.GetNestedType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.GetNestedType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Glu
static Glu()
{
assembly = Assembly.GetExecutingAssembly();//Assembly.Load("OpenTK.OpenGL");
glClass = assembly.GetType("OpenTK.OpenGL.Glu");
delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic);
}
示例2: GL
static GL()
{
glClass = typeof(GL);
delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic);
LoadAll(); // Ensure this class is loaded, since it is no longer visible to the GraphicsContext.LoadAll() method.
}
示例3: Wgl
static Wgl()
{
glClass = typeof(Wgl);
delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic);
// 'Touch' Imports class to force initialization. We don't want anything yet, just to have
// this class ready.
if (Imports.FunctionMap != null) { }
ReloadFunctions();
}
示例4: DefineTransport
public static void DefineTransport(this BusConfiguration builder, IDictionary<string, string> settings, Type endpointBuilderType)
{
if (!settings.ContainsKey("Transport"))
{
settings = Transports.Default.Settings;
}
const string typeName = "ConfigureTransport";
var transportType = Type.GetType(settings["Transport"]);
var transportTypeName = "Configure" + transportType.Name;
var configurerType = endpointBuilderType.GetNestedType(typeName) ??
Type.GetType(transportTypeName, false);
if (configurerType != null)
{
var configurer = Activator.CreateInstance(configurerType);
dynamic dc = configurer;
dc.Configure(builder);
return;
}
builder.UseTransport(transportType).ConnectionString(settings["Transport.ConnectionString"]);
}
示例5: DefinePersistence
public static void DefinePersistence(this BusConfiguration config, IDictionary<string, string> settings, Type endpointBuilderType)
{
if (!settings.ContainsKey("Persistence"))
{
settings = Persistence.Default.Settings;
}
var persistenceType = Type.GetType(settings["Persistence"]);
var typeName = "Configure" + persistenceType.Name;
var configurerType = endpointBuilderType.GetNestedType("ConfigurePersistence") ?? Type.GetType(typeName, false);
if (configurerType != null)
{
var configurer = Activator.CreateInstance(configurerType);
dynamic dc = configurer;
dc.Configure(config);
return;
}
config.UsePersistence(persistenceType);
}
示例6: DefineTransport
public static void DefineTransport(this BusConfiguration config, IDictionary<string, string> settings, Type endpointBuilderType)
{
if (!settings.ContainsKey("Transport"))
{
settings = Transports.Default.Settings;
}
const string typeName = "ConfigureTransport";
var transportType = Type.GetType(settings["Transport"]);
var transportTypeName = "Configure" + transportType.Name;
var configurerType = endpointBuilderType.GetNestedType(typeName) ??
Type.GetType(transportTypeName, false);
if (configurerType != null)
{
var configurer = Activator.CreateInstance(configurerType);
dynamic dc = configurer;
dc.Configure(config);
var cleanupMethod = configurer.GetType().GetMethod("Cleanup", BindingFlags.Public | BindingFlags.Instance);
config.GetSettings().Set("CleanupTransport", cleanupMethod != null ? configurer : new Cleaner());
return;
}
config.UseTransport(transportType).ConnectionString(settings["Transport.ConnectionString"]);
}
示例7: absOpenTKDllImportLoader
protected absOpenTKDllImportLoader(Type loader)
{
pDllImportClass = loader.GetNestedType("DllImports", BindingFlags.Public | BindingFlags.NonPublic);
var funcs = pDllImportClass.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
//if (funcs == null)
// throw new ApplicationException("Failed to find any static functions in DllImports??");
pDllImportMap = new SortedList<string, MethodInfo>();
foreach (var m in funcs)
pDllImportMap.Add(m.Name, m);
}
示例8: LoadExtensions
/// <internal />
/// <summary>Loads all extensions for the specified class. This function is intended
/// for OpenGL, Wgl, Glx, OpenAL etc.</summary>
/// <param name="type">The class to load extensions for.</param>
/// <remarks>
/// <para>The Type must contain a nested class called "Delegates".</para>
/// <para>
/// The Type must also implement a static function called LoadDelegate with the
/// following signature:
/// <code>static Delegate LoadDelegate(string name, Type signature)</code>
/// </para>
/// <para>This function allocates memory.</para>
/// </remarks>
internal static void LoadExtensions(Type type)
{
// Using reflection is more than 3 times faster than directly loading delegates on the first
// run, probably due to code generation overhead. Subsequent runs are faster with direct loading
// than with reflection, but the first time is more significant.
int supported = 0;
Type extensions_class = type.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (extensions_class == null)
throw new InvalidOperationException("The specified type does not have any loadable extensions.");
FieldInfo[] delegates = extensions_class.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (delegates == null)
throw new InvalidOperationException("The specified type does not have any loadable extensions.");
MethodInfo load_delegate_method_info = type.GetMethod("LoadDelegate", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (load_delegate_method_info == null)
throw new InvalidOperationException(type.ToString() + " does not contain a static LoadDelegate method.");
LoadDelegateFunction LoadDelegate = (LoadDelegateFunction)Delegate.CreateDelegate(
typeof(LoadDelegateFunction), load_delegate_method_info);
Debug.Write("Load extensions for " + type.ToString() + "... ");
System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
time.Reset();
time.Start();
foreach (FieldInfo f in delegates)
{
Delegate d = LoadDelegate(f.Name, f.FieldType);
if (d != null)
++supported;
f.SetValue(null, d);
}
FieldInfo rebuildExtensionList = type.GetField("rebuildExtensionList", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (rebuildExtensionList != null)
rebuildExtensionList.SetValue(null, true);
time.Stop();
Debug.Print("{0} extensions loaded in {1} ms.", supported, time.ElapsedMilliseconds);
time.Reset();
}
示例9: cbParser_SelectedIndexChanged
private void cbParser_SelectedIndexChanged(object sender, EventArgs e)
{
clbSubParsers.Items.Clear();
if (cbParser.SelectedIndex > -1)
{
m_parser = m_loader[cbParser.SelectedIndex];
var subparsers = m_parser.GetNestedType("SubParsers");
if (subparsers != null)
{
int index = 0;
foreach (var sub in Enum.GetValues(subparsers))
{
clbSubParsers.Items.Add(sub.ToString());
clbSubParsers.SetItemChecked(index++, true);
}
}
}
}
示例10: GetNestedTypePortable
public static Type GetNestedTypePortable(Type type, string name)
{
return type.GetNestedType(name);
}
示例11: PopupButtonPanelHelper
static PopupButtonPanelHelper ()
{
Assembly swfAssembly = Assembly.GetAssembly (typeof (Control));
pbpType = swfAssembly.GetType ("System.Windows.Forms.PopupButtonPanel");
pbType = pbpType.GetNestedType ("PopupButton", BindingFlags.NonPublic);
performClickMethod = pbType.GetMethod ("PerformClick",
BindingFlags.Instance |
BindingFlags.NonPublic);
}
示例12: FindNestedType
/// <summary>
/// Find a nested type defined in this class or a base class.
/// </summary>
/// <param name="searchType">The class to search.</param>
/// <param name="className">The name of the class to find.</param>
/// <returns>The given nested type or null if not found.</returns>
private static Type FindNestedType(Type searchType, string className)
{
Type nestedType = null;
// if an enumSource type has not been defined, look up the original class hierarchy until we find it
for (; nestedType == null && searchType != null; searchType = searchType.BaseType)
nestedType = searchType.GetNestedType(className);
return nestedType;
}
示例13: SetHunspellDelegate
private static void SetHunspellDelegate(Type marshalType, MethodInfo getDelegateMethod, string call, string delegateName)
{
var delegateField = marshalType.GetField(call, BindingFlags.NonPublic | BindingFlags.Static);
var delegateType = marshalType.GetNestedType(delegateName, BindingFlags.NonPublic);
delegateField.SetValue(null, getDelegateMethod.Invoke(null, new object[] { call, delegateType }));
}
示例14: Get
public object Get(string name, object instance, Type type, params object[] arguments)
{
Type nested = type.GetNestedType(name, ObjectBinder.NestedTypeFilter);
if (nested == null) return NoResult;
return nested;
}
示例15: LinkProcAddressImports
/// <summary>
/// Link delegates fields using import declarations.
/// </summary>
/// <param name="path">
/// A <see cref="System.String"/> that specifies the assembly file path containing the import functions.
/// </param>
/// <param name="type">
/// A <see cref="System.Type"/> that specifies the type used for detecting import declarations and delegates fields.
/// </param>
/// <param name="getAddress">
/// A <see cref="GetAddressDelegate"/> used for getting function pointers. This parameter is dependent on the currently running platform.
/// </param>
/// <param name="sImportMap">
/// A <see cref="T:SortedList{String, MethodIndo}"/> mapping a <see cref="MethodInfo"/> with the relative function name.
/// </param>
/// <param name="sDelegates">
/// A <see cref="T:List{FieldInfo}"/> listing <see cref="FieldInfo"/> related to function delegates.
/// </param>
/// <remarks>
/// <para>
/// The type <paramref name="type"/> shall have defined a nested class named "UnsafeNativeMethods" specifying the import declarations and a nested
/// class named "Delagates" specifying the delegate fields.
/// </para>
/// </remarks>
private static void LinkProcAddressImports(string path, Type type, GetAddressDelegate getAddress, out SortedList<string, MethodInfo> sImportMap, out List<FieldInfo> sDelegates)
{
Type impClass = type.GetNestedType("UnsafeNativeMethods", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
Debug.Assert(impClass != null);
Type delClass = type.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
Debug.Assert(delClass != null);
// Query imports declarations
MethodInfo[] iMethods = impClass.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
sImportMap = new SortedList<string, MethodInfo>(iMethods.Length);
foreach (MethodInfo m in iMethods)
sImportMap.Add(m.Name, m);
// Query delegates declarations
sDelegates = new List<FieldInfo>(delClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic));
foreach (FieldInfo fi in sDelegates) {
Delegate pDelegate = null;
string pImportName = fi.Name.Substring(1);
IntPtr mAddr = getAddress(path, pImportName);
if (mAddr != IntPtr.Zero) {
// Try to load external symbol
if ((pDelegate = Marshal.GetDelegateForFunctionPointer(mAddr, fi.FieldType)) == null) {
MethodInfo mInfo;
if (sImportMap.TryGetValue(pImportName, out mInfo) == true)
pDelegate = Delegate.CreateDelegate(fi.FieldType, mInfo);
}
if (pDelegate != null)
fi.SetValue(null, pDelegate);
}
}
}