本文整理汇总了C#中ITypeDefOrRef.ToTypeSig方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefOrRef.ToTypeSig方法的具体用法?C# ITypeDefOrRef.ToTypeSig怎么用?C# ITypeDefOrRef.ToTypeSig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefOrRef
的用法示例。
在下文中一共展示了ITypeDefOrRef.ToTypeSig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddInitializeArrayCode
public void AddInitializeArrayCode(Block block, int start, int numToRemove, ITypeDefOrRef elementType, byte[] data) {
int index = start;
block.Replace(index++, numToRemove, Instruction.CreateLdcI4(data.Length / elementType.ToTypeSig().ElementType.GetPrimitiveSize()));
block.Insert(index++, OpCodes.Newarr.ToInstruction(elementType));
block.Insert(index++, OpCodes.Dup.ToInstruction());
block.Insert(index++, OpCodes.Ldtoken.ToInstruction((IField)Create(data)));
block.Insert(index++, OpCodes.Call.ToInstruction((IMethod)InitializeArrayMethod));
}
示例2: ResolveTypeOperand
private MosaType ResolveTypeOperand(ITypeDefOrRef operand, GenericArgumentResolver resolver)
{
return metadata.Loader.GetType(resolver.Resolve(operand.ToTypeSig()));
}
示例3: ApplyGenerics
TypeSpec ApplyGenerics(ITypeDefOrRef type, IList<TypeSig> generics)
{
ClassOrValueTypeSig typeSig = type.ToTypeSig().ToClassOrValueTypeSig();
GenericInstSig genericSig = new GenericInstSig(typeSig, generics);
return new TypeSpecUser(genericSig);
}
示例4: GetUnknownValue
static Value GetUnknownValue(ITypeDefOrRef type) {
return GetUnknownValue(type.ToTypeSig(false));
}
示例5: WriteToolTipType
void WriteToolTipType(ITextOutput output, ITypeDefOrRef type, bool useNamespaces, bool usePrimitiveTypeName = true, IHasCustomAttribute typeAttributes = null)
{
var td = type as TypeDef;
if (td == null && type is TypeRef)
td = ((TypeRef)type).Resolve();
if (td == null ||
td.GenericParameters.Count == 0 ||
(td.DeclaringType != null && td.DeclaringType.GenericParameters.Count >= td.GenericParameters.Count)) {
var options = ConvertTypeOptions.IncludeTypeParameterDefinitions;
if (useNamespaces)
options |= ConvertTypeOptions.IncludeNamespace;
if (!usePrimitiveTypeName)
options |= ConvertTypeOptions.DoNotUsePrimitiveTypeNames;
TypeToString(output, options, type, typeAttributes);
return;
}
var typeSig = type.ToTypeSig();
WriteRefIfByRef(output, typeSig, typeAttributes as ParamDef);
int numGenParams = td.GenericParameters.Count;
if (type.DeclaringType != null) {
var options = ConvertTypeOptions.IncludeTypeParameterDefinitions;
if (useNamespaces)
options |= ConvertTypeOptions.IncludeNamespace;
TypeToString(output, options, type.DeclaringType, null);
output.Write('.', TextTokenType.Operator);
numGenParams = numGenParams - td.DeclaringType.GenericParameters.Count;
if (numGenParams < 0)
numGenParams = 0;
}
else if (useNamespaces && !UTF8String.IsNullOrEmpty(td.Namespace)) {
foreach (var ns in td.Namespace.String.Split('.')) {
output.Write(IdentifierEscaper.Escape(ns), TextTokenType.NamespacePart);
output.Write('.', TextTokenType.Operator);
}
}
output.Write(IdentifierEscaper.Escape(RemoveGenericTick(td.Name)), TextTokenHelper.GetTextTokenType(td));
var genParams = td.GenericParameters.Skip(td.GenericParameters.Count - numGenParams).ToArray();
WriteToolTipGenerics(output, genParams, TextTokenType.TypeGenericParameter);
}
示例6: createByRefType
static ByRefSig createByRefType(ITypeDefOrRef elementType)
{
if (elementType == null)
return null;
return new ByRefSig(elementType.ToTypeSig());
}
示例7: GetArgumentType
/// <summary>
/// Returns an argument type
/// </summary>
/// <param name="methodSig">Method signature</param>
/// <param name="declaringType">Declaring type (only needed if it's an instance method)</param>
/// <returns>The type or <c>null</c> if it doesn't exist</returns>
public TypeSig GetArgumentType(MethodSig methodSig, ITypeDefOrRef declaringType) {
if (methodSig == null)
return null;
int index = GetParameterIndex();
if (index == 0 && methodSig.ImplicitThis)
return declaringType.ToTypeSig(); //TODO: Should be ByRef if value type
if (methodSig.ImplicitThis)
index--;
return methodSig.Params.Get(index, null);
}
示例8: WriteType
void WriteType(ITypeDefOrRef type, bool useNamespaces, bool useTypeKeywords) {
var td = type as TypeDef;
if (td == null && type is TypeRef)
td = ((TypeRef)type).Resolve();
if (td == null ||
td.GenericParameters.Count == 0 ||
(td.DeclaringType != null && td.DeclaringType.GenericParameters.Count >= td.GenericParameters.Count)) {
var oldFlags = this.flags;
this.flags &= ~(SimplePrinterFlags.ShowNamespaces | SimplePrinterFlags.ShowTypeKeywords);
if (useNamespaces)
this.flags |= SimplePrinterFlags.ShowNamespaces;
if (useTypeKeywords)
this.flags |= SimplePrinterFlags.ShowTypeKeywords;
Write(type);
this.flags = oldFlags;
return;
}
var typeSig = type.ToTypeSig();
int numGenParams = td.GenericParameters.Count;
if (type.DeclaringType != null) {
var oldFlags = this.flags;
this.flags &= ~(SimplePrinterFlags.ShowNamespaces | SimplePrinterFlags.ShowTypeKeywords);
if (useNamespaces)
this.flags |= SimplePrinterFlags.ShowNamespaces;
Write(type.DeclaringType);
this.flags = oldFlags;
OutputWrite(".", TextTokenKind.Operator);
numGenParams = numGenParams - td.DeclaringType.GenericParameters.Count;
if (numGenParams < 0)
numGenParams = 0;
}
else if (useNamespaces && !UTF8String.IsNullOrEmpty(td.Namespace)) {
foreach (var ns in td.Namespace.String.Split('.')) {
WriteIdentifier(ns, TextTokenKind.NamespacePart);
OutputWrite(".", TextTokenKind.Operator);
}
}
WriteIdentifier(RemoveGenericTick(td.Name), TextTokenKindUtils.GetTextTokenType(td));
WriteToken(type);
var genParams = td.GenericParameters.Skip(td.GenericParameters.Count - numGenParams).ToArray();
WriteGenerics(genParams, TextTokenKind.TypeGenericParameter);
}