本文整理汇总了C#中Module.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Module.GetType方法的具体用法?C# Module.GetType怎么用?C# Module.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyType
public static void VerifyType(TypeBuilder type, Module module, TypeBuilder declaringType, string name, TypeAttributes attributes, Type baseType, int size, PackingSize packingSize, Type[] implementedInterfaces)
{
Assert.Same(module, type.Module);
Assert.Same(module.Assembly, type.Assembly);
Assert.Equal(name, type.Name);
if (declaringType == null)
{
Assert.Equal(GetFullName(name), type.FullName);
}
else
{
Assert.Equal(GetFullName(declaringType.Name) + "+" + GetFullName(type.Name), type.FullName);
}
Assert.Equal(attributes, type.Attributes);
Assert.Equal(declaringType?.AsType(), type.DeclaringType);
Assert.Equal(baseType, type.BaseType);
Assert.Equal(size, type.Size);
Assert.Equal(packingSize, type.PackingSize);
Assert.Equal(implementedInterfaces ?? new Type[0], type.ImplementedInterfaces);
if (declaringType == null && !type.IsInterface && (implementedInterfaces == null || implementedInterfaces.Length == 0))
{
Type createdType = type.CreateTypeInfo().AsType();
Assert.Equal(createdType, module.GetType(name, false, false));
Assert.Equal(createdType, module.GetType(name, true, false));
// [ActiveIssue(10989, TestPlatforms.AnyUnix)]
// Assert.Equal(createdType, module.GetType(name, true, true));
// Assert.Equal(createdType, module.GetType(name.ToLowerInvariant(), true, true));
// Assert.Equal(createdType, module.GetType(name.ToUpperInvariant(), true, true));
}
}
示例2: GetDescription
public string GetDescription(Module module, string path)
{
var assembly = module.GetType().Assembly;
if (assembly.IsDynamic)
{
return string.Empty;
}
var moduleName = string.Concat(module.GetType().FullName, ".resources");
var resourceName = assembly
.GetManifestResourceNames()
.FirstOrDefault(x => x.Equals(moduleName, StringComparison.OrdinalIgnoreCase));
if (resourceName != null)
{
var manager = new ResourceManager(resourceName.Replace(".resources", string.Empty), assembly);
return manager.GetString(path);
}
return string.Empty;
}
示例3: GetType
private Type GetType(Module mod, string name)
{
try
{
return mod.GetType(name);
}
catch (ArgumentException)
{
}
catch (FileLoadException x)
{
// this can only happen if the assembly was loaded in the ReflectionOnly
// context and the requested type references a type in another assembly
// that cannot be found in the ReflectionOnly context
// TODO figure out what other exceptions Assembly.GetType() can throw
Tracer.Info(Tracer.Runtime, x.Message);
}
return null;
}
示例4: RecursiveCheckModule
protected bool RecursiveCheckModule(Module auraType)
{
Type newType = auraType.GetType();
while (newType != typeof(System.Object))
{
if (newType == typeof(Tick))
{
return true;
}
else
{
newType = newType.BaseType;
}
}
return false;
}
示例5: LookupType
private TypeNode LookupType(string/*!*/ nameSpace, string/*!*/ name, string assemblyName, out Module module)
{
Identifier namespaceId = Identifier.For(nameSpace);
Identifier nameId = Identifier.For(name);
module = this.module;
//^ assume module != null;
if (assemblyName == null)
{
TypeNode t = module.GetType(namespaceId, nameId);
if (t != null) return t;
module = CoreSystemTypes.SystemAssembly;
return CoreSystemTypes.SystemAssembly.GetType(namespaceId, nameId);
}
//See if the type is in one of the assemblies explicitly referenced by the current module
AssemblyReferenceList arefs = module.AssemblyReferences;
for (int i = 0, n = arefs == null ? 0 : arefs.Count; i < n; i++)
{
AssemblyReference aref = arefs[i];
if (aref != null && aref.StrongName == assemblyName && aref.Assembly != null)
{
module = aref.Assembly;
return aref.Assembly.GetType(namespaceId, nameId);
}
}
//Construct an assembly reference and probe for it
AssemblyReference aRef = new AssemblyReference(assemblyName);
AssemblyNode referringAssembly = this.module as AssemblyNode;
if (referringAssembly != null && (referringAssembly.Flags & AssemblyFlags.Retargetable) != 0)
aRef.Flags |= AssemblyFlags.Retargetable;
AssemblyNode aNode = this.GetAssemblyFromReference(aRef);
if (aNode != null)
{
module = aNode;
TypeNode result = aNode.GetType(namespaceId, nameId);
return result;
}
return null;
}