本文整理汇总了C#中Mono.Cecil.ImportGenericContext类的典型用法代码示例。如果您正苦于以下问题:C# ImportGenericContext类的具体用法?C# ImportGenericContext怎么用?C# ImportGenericContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImportGenericContext类属于Mono.Cecil命名空间,在下文中一共展示了ImportGenericContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ImportType
public TypeReference ImportType(TypeReference type, ImportGenericContext context)
{
if (type.IsTypeSpecification ())
return ImportTypeSpecification (type, context);
var reference = new TypeReference (
type.Namespace,
type.Name,
module,
ImportScope (type.Scope),
type.IsValueType);
MetadataSystem.TryProcessPrimitiveTypeReference (reference);
if (type.IsNested)
reference.DeclaringType = ImportType (type.DeclaringType, context);
if (type.HasGenericParameters)
ImportGenericParameters (reference, type);
return reference;
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:22,代码来源:Import.cs
示例2: ImportField
public FieldReference ImportField(FieldReference field, ImportGenericContext context)
{
var declaring_type = ImportType (field.DeclaringType, context);
context.Push (declaring_type);
try {
return new FieldReference {
Name = field.Name,
DeclaringType = declaring_type,
FieldType = ImportType (field.FieldType, context),
};
} finally {
context.Pop ();
}
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:15,代码来源:Import.cs
示例3: ImportMethod
public MethodReference ImportMethod(MethodReference method, ImportGenericContext context)
{
if (method.IsGenericInstance)
return ImportMethodSpecification (method, context);
var declaring_type = ImportType (method.DeclaringType, context);
var reference = new MethodReference {
Name = method.Name,
HasThis = method.HasThis,
ExplicitThis = method.ExplicitThis,
DeclaringType = declaring_type,
CallingConvention = method.CallingConvention,
};
if (method.HasGenericParameters)
ImportGenericParameters (reference, method);
context.Push (reference);
try {
reference.ReturnType = ImportType (method.ReturnType, context);
if (!method.HasParameters)
return reference;
var reference_parameters = reference.Parameters;
var parameters = method.Parameters;
for (int i = 0; i < parameters.Count; i++)
reference_parameters.Add (
new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
return reference;
} finally {
context.Pop();
}
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:37,代码来源:Import.cs
示例4: ImportTypeSpecification
TypeReference ImportTypeSpecification(Type type, ImportGenericContext context)
{
if (type.IsByRef)
return new ByReferenceType (ImportType (type.GetElementType (), context));
if (type.IsPointer)
return new PointerType (ImportType (type.GetElementType (), context));
if (type.IsArray)
return new ArrayType (ImportType (type.GetElementType (), context), type.GetArrayRank ());
if (type.IsGenericType)
return ImportGenericInstance (type, context);
if (type.IsGenericParameter)
return ImportGenericParameter (type, context);
throw new NotSupportedException (type.FullName);
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:19,代码来源:Import.cs
示例5: ImportGenericParameter
TypeReference ImportGenericParameter(Type type, ImportGenericContext context, ISRImportMapper mapper)
{
if (context.IsEmpty)
throw new InvalidOperationException ();
if (type.DeclaringMethod != null)
return context.MethodParameter(type.DeclaringMethod, type.GenericParameterPosition, mapper);
if (type.DeclaringType != null)
return context.TypeParameter(type.DeclaringType, type.GenericParameterPosition, mapper);
throw new InvalidOperationException();
}
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:13,代码来源:Import.cs
示例6: ImportGenericParameter
static TypeReference ImportGenericParameter(Type type, ImportGenericContext context)
{
if (context.IsEmpty)
throw new InvalidOperationException ();
if (type.DeclaringMethod != null)
{
return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);
}
if (type.DeclaringType != null)
{
return context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);
}
throw new InvalidOperationException();
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:15,代码来源:Import.cs
示例7: ImportGenericInstance
TypeReference ImportGenericInstance(Type type, ImportGenericContext context)
{
var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition);
var instance = new GenericInstanceType (element_type);
var arguments = type.GetGenericArguments ();
var instance_arguments = instance.GenericArguments;
context.Push (element_type);
try {
for (int i = 0; i < arguments.Length; i++)
instance_arguments.Add (ImportType (arguments [i], context));
return instance;
} finally {
context.Pop ();
}
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:17,代码来源:Import.cs
示例8: ImportType
internal TypeReference ImportType(TypeReference type, ImportGenericContext context,
IImportMapper mapper)
{
if (type.IsTypeSpecification())
return ImportTypeSpecification(type, context, mapper);
var mapped = mapper.MapType(type);
if (mapped == null)
mapped = type;
var reference = new TypeReference(
mapped.Namespace,
mapped.Name,
module,
ImportScope(mapper.MapMetadataScope(type.Scope)),
mapped.IsValueType);
MetadataSystem.TryProcessPrimitiveTypeReference(reference);
if (mapped.IsNested)
reference.DeclaringType = ImportType(mapped.DeclaringType, context, mapper);
if (mapped.HasGenericParameters)
ImportGenericParameters(reference, mapped);
return reference;
}
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:27,代码来源:Import.cs
示例9: ImportField
internal FieldReference ImportField(FieldReference field, ImportGenericContext context,
IImportMapper mapper)
{
var mapped = mapper.MapField(field);
if (mapped == null)
mapped = field;
var declaring_type = ImportType(mapped.DeclaringType, context, mapper);
context.Push (declaring_type);
try {
return new FieldReference {
Name = mapped.Name,
DeclaringType = declaring_type,
FieldType = ImportType(mapped.FieldType, context, mapper),
};
} finally {
context.Pop ();
}
}
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:20,代码来源:Import.cs
示例10: ImportMethodSpecification
MethodSpecification ImportMethodSpecification(MethodReference method, ImportGenericContext context)
{
if (!method.IsGenericInstance)
throw new NotSupportedException ();
var instance = (GenericInstanceMethod) method;
var element_method = ImportMethod (instance.ElementMethod, context);
var imported_instance = new GenericInstanceMethod (element_method);
var arguments = instance.GenericArguments;
var imported_arguments = imported_instance.GenericArguments;
for (int i = 0; i < arguments.Count; i++)
imported_arguments.Add (ImportType (arguments [i], context));
return imported_instance;
}
开发者ID:KonajuGames,项目名称:cecil,代码行数:17,代码来源:Import.cs
示例11: ImportGenericParameter
static TypeReference ImportGenericParameter(Type type, ImportGenericContext context)
{
if (context.IsEmpty)
throw new InvalidOperationException ();
#if !NETFX_CORE
if (type.DeclaringMethod != null)
return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);
#else
var typeInfo = type.GetTypeInfo();
if (typeInfo.DeclaringMethod != null)
return context.MethodParameter(typeInfo.DeclaringMethod.Name, type.GenericParameterPosition);
#endif
if (type.DeclaringType != null)
return context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);
throw new InvalidOperationException();
}
开发者ID:terurou,项目名称:cecil,代码行数:19,代码来源:Import.cs
注:本文中的Mono.Cecil.ImportGenericContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论