當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。