本文整理汇总了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;
}
}
示例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");
}
}
示例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);
}
}
示例4: RainMaker
public RainMaker(Game game)
: base(game)
{
terrariaAssembly = Assembly.GetAssembly(game.GetType());
main = terrariaAssembly.GetType("Terraria.Main");
worldGen = terrariaAssembly.GetType("Terraria.WorldGen");
}
示例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);
}
示例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;
}
}
示例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");
}
示例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;
}
示例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);
}
示例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
}
示例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");
}
示例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);
}
示例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");
}
示例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;
}
示例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) });
}