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


C# Assembly.GetType方法代码示例

本文整理汇总了C#中System.Reflection.Assembly.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetType方法的具体用法?C# Assembly.GetType怎么用?C# Assembly.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Assembly的用法示例。


在下文中一共展示了Assembly.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Build

        public Test Build(string assemblyName, string testName, bool autoSuites)
        {
            if (testName == null || testName == string.Empty)
                return Build(assemblyName, autoSuites);

            // Change currentDirectory in case assembly references unmanaged dlls
            // and so that any addins are able to access the directory easily.
            using (new DirectorySwapper(Path.GetDirectoryName(assemblyName)))
            {
                this.assembly = Load(assemblyName);
                if (assembly == null) return null;

                // If provided test name is actually the name of
                // a type, we handle it specially
                Type testType = assembly.GetType(testName);
                if (testType != null)
                    return Build(assemblyName, testType, autoSuites);

                // Assume that testName is a namespace and get all fixtures in it
                IList fixtures = GetFixtures(assembly, testName);
                if (fixtures.Count > 0)
                    return BuildTestAssembly(assemblyName, fixtures, autoSuites);

                return null;
            }
        }
开发者ID:jimgraham,项目名称:visual-nunit,代码行数:26,代码来源:TestBuilder.cs

示例2: LoadBuildManagerAssembly

        /// <summary>
        /// Loads the correct assembly and type information for accessing
        /// the IVsBuildManagerAccessor service.
        /// </summary>
        private static void LoadBuildManagerAssembly()
        {
            try
            {
                BuildManagerAdapter.buildManagerAssembly = Assembly.Load("Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                BuildManagerAdapter.buildManagerAccessorType = buildManagerAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.SVsBuildManagerAccessor");
                BuildManagerAdapter.buildManagerAccessorInterfaceType = buildManagerAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.IVsBuildManagerAccessor");

                if (BuildManagerAdapter.buildManagerAccessorType != null && BuildManagerAdapter.buildManagerAccessorInterfaceType != null)
                {
                    return;
                }
            }
            catch
            {
            }

            // If the first one didn't work, this one must. Don't swallow
            // exceptions here.
            BuildManagerAdapter.buildManagerAssembly = Assembly.Load("Microsoft.VisualStudio.CommonIDE, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            BuildManagerAdapter.buildManagerAccessorType = buildManagerAssembly.GetType("Microsoft.VisualStudio.CommonIDE.BuildManager.SVsBuildManagerAccessor");
            BuildManagerAdapter.buildManagerAccessorInterfaceType = buildManagerAssembly.GetType("Microsoft.VisualStudio.CommonIDE.BuildManager.IVsBuildManagerAccessor");

            if (BuildManagerAdapter.buildManagerAccessorType == null || BuildManagerAdapter.buildManagerAccessorInterfaceType == null)
            {
                throw new TypeLoadException("TypeLoadException: Microsoft.VisualStudio.CommonIDE.BuildManager.SVsBuildManagerAccessor");
            }
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:32,代码来源:buildmanageradapter.cs

示例3: CreateUsingLateBinding

        static void CreateUsingLateBinding(Assembly asm)
        {
            try
            {
                // Get metadata for the Minivan type.
                Type miniVan = asm.GetType("CarLibrary.MiniVan");
                // Create the Minivan on the fly.
                object obj = Activator.CreateInstance(miniVan); // object, can't cast
                Console.WriteLine("Created a {0} using late binding!", obj);
                // Get info for TurboBoost.
                MethodInfo mi = miniVan.GetMethod("TurboBoost");
                // Invoke method ('null' for no parameters).
                mi.Invoke(obj, null);

                // First, get a metadata description of the sports car.
                Type sport = asm.GetType("CarLibrary.SportsCar");
                // Now, create the sports car.
                object sportobj = Activator.CreateInstance(sport);
                // Invoke TurnOnRadio() with arguments.
                MethodInfo mi2 = sport.GetMethod("TurnOnRadio");
                mi2.Invoke(obj, new object[] { true, 2 });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:wordtinker,项目名称:c-sharp,代码行数:27,代码来源:Program.cs

示例4: RainMaker

 public RainMaker(Game game)
     : base(game)
 {
     terrariaAssembly = Assembly.GetAssembly(game.GetType());
     main = terrariaAssembly.GetType("Terraria.Main");
     worldGen = terrariaAssembly.GetType("Terraria.WorldGen");
 }
开发者ID:RomSteady,项目名称:RomTerraria,代码行数:7,代码来源:RainMaker.cs

示例5: MainForm

        public MainForm()
        {
            InitializeComponent();

            _tasksAssembly = Assembly.LoadFrom(ConfigurationManager.AppSettings["TasksAssembly"]);
            _callbacksAssembly = Assembly.LoadFrom(ConfigurationManager.AppSettings["CallbacksAssembly"]);

            // TODO: implement a prefix for each task description, don't use Count!
            _taskDescriptionToObject = new Dictionary<string, TaskObject>(ConfigurationManager.AppSettings.Count);
            _concreteEventArgsToTaskDescription = new Dictionary<Type, string>(ConfigurationManager.AppSettings.Count);

            foreach (var key in ConfigurationManager.AppSettings.AllKeys)
            {
                if (key != "TasksAssembly" && key != "CallbacksAssembly")
                {
                    String[] concreteTypeNamesAndOperandsRequired = ConfigurationManager.AppSettings[key].Split(',');
                    Type taskConcreteType = _tasksAssembly.GetType(concreteTypeNamesAndOperandsRequired[0]);
                    Type taskCallbackType = _callbacksAssembly.GetType(concreteTypeNamesAndOperandsRequired[1]);
                    Type taskConcreteEventArgsType = _callbacksAssembly.GetType(concreteTypeNamesAndOperandsRequired[2]);

                    _taskDescriptionToObject.Add(key, new TaskObject(taskConcreteType, taskCallbackType, Int32.Parse(concreteTypeNamesAndOperandsRequired[3]),
                        "true" == concreteTypeNamesAndOperandsRequired[4]));
                    _concreteEventArgsToTaskDescription.Add(taskConcreteEventArgsType, key);
                    tasksComboBox.Items.Add(key);
                }
            }

            _resultDelegate = new NewResultDelegate(AddResultToList);
        }
开发者ID:rycle,项目名称:BlockingTaskQueue,代码行数:29,代码来源:SimulatorForm.cs

示例6: ResolveAdapter

        private static object ResolveAdapter(Assembly assembly, Type interfaceType)
        {
            string typeName = MakeAdapterTypeName(interfaceType);

            try
            {
                // Is there an override?
                Type type = assembly.GetType(typeName + "Override");
                if (type != null)
                    return Activator.CreateInstance(type);

                // Fall back to a default implementation
                type = assembly.GetType(typeName);
                if (type != null)
                    return Activator.CreateInstance(type);

                // Fallback to looking in this assembly for a default
                type = typeof(ProbingAdapterResolver).Assembly.GetType(typeName);

                return type != null ? Activator.CreateInstance(type) : null;
            }
            catch
            {
                return null;
            }
        }
开发者ID:sliplow,项目名称:LisaChowArtwork,代码行数:26,代码来源:ProbingAdapterResolver.cs

示例7: SandboxGameAssemblyWrapper

        protected SandboxGameAssemblyWrapper()
        {
            m_instance = this;
            m_isDebugging = false;
            m_isUsingCommonProgramData = false;
            m_isInSafeMode = false;

            m_assembly = Assembly.UnsafeLoadFrom("Sandbox.Game.dll");

            m_mainGameType = m_assembly.GetType(MainGameNamespace + "." + MainGameClass);
            m_serverCoreType = m_assembly.GetType(ServerCoreClass);

            m_mainGameInstanceField = m_mainGameType.GetField(MainGameInstanceField, BindingFlags.Static | BindingFlags.Public);
            m_configContainerField = m_mainGameType.GetField(MainGameConfigContainerField, BindingFlags.Static | BindingFlags.Public);
            m_configContainerType = m_configContainerField.FieldType;
            m_serverCoreNullRender = m_serverCoreType.GetField(ServerCoreNullRenderField, BindingFlags.Public | BindingFlags.Static);

            m_configContainerDedicatedDataField = m_configContainerType.GetField(ConfigContainerDedicatedDataField, BindingFlags.NonPublic | BindingFlags.Instance);
            m_setConfigWorldName = m_configContainerType.GetMethod(ConfigContainerSetWorldName, BindingFlags.Public | BindingFlags.Instance);

            m_lastProfilingOutput = DateTime.Now;
            m_countQueuedActions = 0;
            m_averageQueuedActions = 0;

            Console.WriteLine("Finished loading SandboxGameAssemblyWrapper");
        }
开发者ID:noxer,项目名称:SE-Community-Mod-API,代码行数:26,代码来源:SandboxGameAssemblyWrapper.cs

示例8: GetTypeFromAssembly

        private static Type GetTypeFromAssembly(Assembly assembly, string dtoObjectName, bool isNameFullyQualified, string alternateNamespace)
        {
            string typeName;
            Type type = null;

            if (assembly != null)
            {
                var asmName = assembly.FullName.Substring(0, assembly.FullName.IndexOf(','));
                typeName = isNameFullyQualified ? dtoObjectName : string.Format("{0}.{1}", asmName, dtoObjectName);
                type = assembly.GetType(typeName);

                if (type == null)
                {
                    if (!string.IsNullOrWhiteSpace(alternateNamespace))
                    {
                        typeName = string.Format("{0}.{1}", alternateNamespace, dtoObjectName);
                    }
                    else
                    {
                        typeName = dtoObjectName;
                    }
                    type = assembly.GetType(typeName);
                }
            }

            return type;
        }
开发者ID:wald-tq,项目名称:aa-validation-from-server,代码行数:27,代码来源:TypeHelper.cs

示例9: FsiLanguageServiceHelper

 public FsiLanguageServiceHelper()
 {
     EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));
     fsiAssembly = Assembly.Load(String.Format("FSharp.VS.FSI, Version={0}.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", dte.Version));
     fsiLanguageServiceType = fsiAssembly.GetType("Microsoft.VisualStudio.FSharp.Interactive.FsiLanguageService");
     sessionsType = fsiAssembly.GetType("Microsoft.VisualStudio.FSharp.Interactive.Session.Sessions");
     fsiWindowType = fsiAssembly.GetType(FsiToolWindowClassName);
 }
开发者ID:panesofglass,项目名称:FSharp.Interactive.Intellisense,代码行数:8,代码来源:FsiLanguageServiceHelper.cs

示例10: SqliteCertificateDatabase

		// At class initialization we try to use reflection to load the
		// Mono.Data.Sqlite assembly: this allows us to use Sqlite as the 
		// default certificate store without explicitly depending on the
		// assembly.
		static SqliteCertificateDatabase ()
		{
#if COREFX
			try {
				if ((sqliteAssembly = Assembly.Load (new AssemblyName ("Microsoft.Data.Sqlite"))) != null) {
					sqliteConnectionClass = sqliteAssembly.GetType ("Microsoft.Data.Sqlite.SqliteConnection");
					sqliteConnectionStringBuilderClass = sqliteAssembly.GetType ("Microsoft.Data.Sqlite.SqliteConnectionStringBuilder");

					// Make sure that the runtime can load the native sqlite library
					var builder = Activator.CreateInstance (sqliteConnectionStringBuilderClass);

					IsAvailable = true;
				}
			} catch (FileNotFoundException) {
			} catch (FileLoadException) {
			} catch (BadImageFormatException) {
			}
#elif !__MOBILE__
			var platform = Environment.OSVersion.Platform;

			try {
				// Mono.Data.Sqlite will only work on Unix-based platforms and 32-bit Windows platforms.
				if (platform == PlatformID.Unix || platform == PlatformID.MacOSX || IntPtr.Size == 4) {
					if ((sqliteAssembly = Assembly.Load ("Mono.Data.Sqlite")) != null) {
						sqliteConnectionClass = sqliteAssembly.GetType ("Mono.Data.Sqlite.SqliteConnection");
						sqliteConnectionStringBuilderClass = sqliteAssembly.GetType ("Mono.Data.Sqlite.SqliteConnectionStringBuilder");

						// Make sure that the runtime can load the native sqlite3 library
						var builder = Activator.CreateInstance (sqliteConnectionStringBuilderClass);
						sqliteConnectionStringBuilderClass.GetProperty ("DateTimeFormat").SetValue (builder, 0, null);

						IsAvailable = true;
					}
				}

				// System.Data.Sqlite is only available for Windows-based platforms.
				if (!IsAvailable && platform != PlatformID.Unix && platform != PlatformID.MacOSX) {
					if ((sqliteAssembly = Assembly.Load ("System.Data.SQLite")) != null) {
						sqliteConnectionClass = sqliteAssembly.GetType ("System.Data.SQLite.SQLiteConnection");
						sqliteConnectionStringBuilderClass = sqliteAssembly.GetType ("System.Data.SQLite.SQLiteConnectionStringBuilder");

						// Make sure that the runtime can load the native sqlite3 library
						var builder = Activator.CreateInstance (sqliteConnectionStringBuilderClass);
						sqliteConnectionStringBuilderClass.GetProperty ("DateTimeFormat").SetValue (builder, 0, null);

						IsAvailable = true;
					}
				}
			} catch (FileNotFoundException) {
			} catch (FileLoadException) {
			} catch (BadImageFormatException) {
			}
#else
			IsAvailable = true;
#endif
		}
开发者ID:surekqomi,项目名称:MimeKit,代码行数:60,代码来源:SqliteCertificateDatabase.cs

示例11: Runable

        public Runable(Assembly assembly, string[] args)
        {
            var constructor = assembly.GetType("Code").GetConstructor(new Type[] { typeof(string[]) });
            _instance = constructor.Invoke(new object[] { args }) as RuntimeBase;
            _instance.Progress += OnProgress;
            _instance.Select += OnSelect;
            _instance.Highlight += OnHighlight;

            _runType = assembly.GetType("Code");
        }
开发者ID:bitsummation,项目名称:pickaxe,代码行数:10,代码来源:Runable.cs

示例12: Bind

		internal static MethodInfo UnhandledExceptionHandler; // object->object
        
        public static void Bind(Assembly integrationAssembly)
        {
            integrationType = integrationAssembly.GetType("ExcelDna.Integration.Integration");

            Type menuManagerType = integrationAssembly.GetType("ExcelDna.Integration.MenuManager");
            addCommandMenu = menuManagerType.GetMethod("AddCommandMenu", BindingFlags.Static | BindingFlags.NonPublic);
            removeCommandMenus = menuManagerType.GetMethod("RemoveCommandMenus", BindingFlags.Static | BindingFlags.NonPublic);

			UnhandledExceptionHandler = integrationType.GetMethod("HandleUnhandledException", BindingFlags.Static | BindingFlags.NonPublic);
        }
开发者ID:ravikp,项目名称:rims.net,代码行数:12,代码来源:IntegrationHelpers.cs

示例13: Zip

        private Zip()
        {
            // Load types
            this.zipAssembly = LoadAssemblyFromResource(ASSEMBLY_RESOURCE_STRING);

            fastZipType = zipAssembly.GetType("ICSharpCode.SharpZipLib.Zip.FastZip");
            fastZipInstance = Activator.CreateInstance(fastZipType);

            zipFileType = zipAssembly.GetType("ICSharpCode.SharpZipLib.Zip.ZipFile");
            zipEntryType = zipAssembly.GetType("ICSharpCode.SharpZipLib.Zip.ZipEntry");
        }
开发者ID:mousetail,项目名称:InstallPad,代码行数:11,代码来源:Zip.cs

示例14: FindTypeInAssembly

 private Type FindTypeInAssembly(Assembly assembly, string typeName)
 {
     var type = assembly.GetType(typeName);
     if (type != null) return type;
     for (int i = 0; i < RazorTypeBuilder.DefaultNamespaceImports.Length; i++)
     {
         type = assembly.GetType(RazorTypeBuilder.DefaultNamespaceImports[i] + "." + typeName);
         if (type != null) return type;
     }
     return null;
 }
开发者ID:rkevinstout,项目名称:Simple.Web,代码行数:11,代码来源:TypeResolver.cs

示例15: ClientReflectionHelper

		static ClientReflectionHelper ()
		{
			SystemAssembly = typeof (Uri).Assembly;
			web_header_collection = SystemAssembly.GetType ("System.Net.WebHeaderCollection");
			headers_all_keys = web_header_collection.GetProperty ("AllKeys").GetGetMethod ();

			headers_get = web_header_collection.GetMethod ("Get", new Type [] { typeof (string) });
			headers_set = web_header_collection.GetMethod ("Set", new Type [] { typeof (string), typeof (string) });

			Type network_credential = SystemAssembly.GetType ("System.Net.NetworkCredential");
			network_credential_ctor = network_credential.GetConstructor (new Type [] { typeof (string), typeof (string), typeof (string) });
		}
开发者ID:kangaroo,项目名称:moon,代码行数:12,代码来源:ClientReflectionHelper.cs


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