当前位置: 首页>>代码示例>>C#>>正文


C# Type.GetNestedType方法代码示例

本文整理汇总了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);
 }
开发者ID:nebenjamin,项目名称:cpsc-431-project,代码行数:7,代码来源:GluHelper.cs

示例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.
        }
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:8,代码来源:GLHelper.cs

示例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();
 }
开发者ID:sinclairzx81,项目名称:vector-cs,代码行数:10,代码来源:WglHelper.cs

示例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"]);
        }
开发者ID:hmemcpy,项目名称:NServiceBus.Jil,代码行数:27,代码来源:ConfigureExtensions.cs

示例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);
        }
开发者ID:james-wu,项目名称:NServiceBus.NHibernate,代码行数:26,代码来源:ConfigureExtensions.cs

示例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"]);
        }
开发者ID:hanin,项目名称:NServiceBus.RavenDB,代码行数:29,代码来源:ConfigureExtensions.cs

示例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);
        }
开发者ID:raggsokk,项目名称:Kraggs.Graphics.OpenGL,代码行数:14,代码来源:absOpenTKDllImportLoader.cs

示例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();
        }
开发者ID:andykorth,项目名称:opentk,代码行数:57,代码来源:Utilities.cs

示例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);
                    }
                }
            }
        }
开发者ID:CarlosX,项目名称:wowhead_parser,代码行数:20,代码来源:FrmMain.cs

示例10: GetNestedTypePortable

 public static Type GetNestedTypePortable(Type type, string name)
 {
     return type.GetNestedType(name);
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:4,代码来源:TypeExtensions.cs

示例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);
		}
开发者ID:mono,项目名称:uia2atk,代码行数:9,代码来源:PopupButtonPanelTest.cs

示例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;
        }
开发者ID:stebet,项目名称:EventSourceProxy,代码行数:16,代码来源:TypeImplementer.cs

示例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 }));
        }
开发者ID:0x49D1,项目名称:DownmarkerWPF,代码行数:8,代码来源:Loader.cs

示例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;
            }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:7,代码来源:ObjectBinderHelpers.cs

示例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);
				}
			}
		}
开发者ID:rhynodegreat,项目名称:OpenGL.Net,代码行数:61,代码来源:KhronosApi.cs


注:本文中的System.Type.GetNestedType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。