本文整理汇总了C#中MetadataToken类的典型用法代码示例。如果您正苦于以下问题:C# MetadataToken类的具体用法?C# MetadataToken怎么用?C# MetadataToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetadataToken类属于命名空间,在下文中一共展示了MetadataToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write(MethodBody body, /*Telerik Authorship*/ MetadataToken methodToken, /*Telerik Authorship*/ MetadataToken localVarToken)
{
var method = new SourceMethod (body.Method);
var instructions = GetInstructions (body);
int count = instructions.Count;
if (count == 0)
return;
var offsets = new int [count];
var start_rows = new int [count];
var start_cols = new int [count];
SourceFile file;
Populate (instructions, offsets, start_rows, start_cols, out file);
var builder = writer.OpenMethod (file.CompilationUnit, 0, method);
for (int i = 0; i < count; i++)
builder.MarkSequencePoint (
offsets [i],
file.CompilationUnit.SourceFile,
start_rows [i],
start_cols [i],
false);
if (body.HasVariables)
AddVariables (body.Variables);
writer.CloseMethod ();
}
示例2: WriteToken
void WriteToken (MetadataToken token)
{
if (token.RID == 0)
m_codeWriter.Write (0);
else
m_codeWriter.Write (token.ToUInt ());
}
示例3: EncodeToken
public uint EncodeToken(MetadataToken token)
{
var index = Array.IndexOf(_tables, token.TokenType);
if (index == -1)
throw new ArgumentException("Table is not supported by this encoder.", "token");
return (token.Rid << _tableIndexBitCount) | (uint)index;
}
示例4: AssemblyNameReference
public AssemblyNameReference(string name, Version version)
{
if (name == null)
throw new ArgumentNullException ("name");
this.name = name;
this.version = Mixin.CheckVersion (version);
this.hash_algorithm = AssemblyHashAlgorithm.None;
this.token = new MetadataToken (TokenType.AssemblyRef);
}
示例5: LookupTokenExtended
/// <summary>
/// This method returns the member with the specified metadata token in the given module. It supports more TokenTypes than the standard Cecil method.
/// </summary>
/// <param name="module"></param>
/// <param name="token"></param>
/// <returns></returns>
internal static IMetadataTokenProvider LookupTokenExtended(this ModuleDefinition module, MetadataToken token)
{
switch (token.TokenType) {
case TokenType.TypeDef:
case TokenType.TypeRef:
case TokenType.MemberRef:
case TokenType.Field:
case TokenType.Method:
case TokenType.MethodSpec:
case TokenType.TypeSpec:
return module.LookupToken(token);
default:
IMetadataTokenProvider provider;
var success = _tokenProviderCache.GetValue(module, InitializeTokenProviderCache).TryGetValue(token.ToUInt32(),
out provider);
return success ? provider : null;
}
}
示例6: AddManifestResource
void AddManifestResource (uint offset, string name, ManifestResourceAttributes flags, MetadataToken impl)
{
ManifestResourceTable mrTable = m_tableWriter.GetManifestResourceTable ();
ManifestResourceRow mrRow = m_rowWriter.CreateManifestResourceRow (
offset,
flags,
m_mdWriter.AddString (name),
impl);
mrTable.Rows.Add (mrRow);
}
示例7: VisitAssemblyLinkedResource
public override void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
{
MetadataToken impl = new MetadataToken (TokenType.AssemblyRef,
(uint) m_asm.MainModule.AssemblyReferences.IndexOf (res.Assembly) + 1);
AddManifestResource (0, res.Name, res.Flags, impl);
}
示例8: ModuleReference
internal ModuleReference()
{
this.token = new MetadataToken (TokenType.ModuleRef);
}
示例9: PatchRawFatMethod
void PatchRawFatMethod (ByteBuffer buffer, MethodSymbols symbols, CodeWriter writer, out MetadataToken local_var_token)
{
var flags = ReadUInt16 ();
buffer.WriteUInt16 (flags);
buffer.WriteUInt16 (ReadUInt16 ());
symbols.code_size = ReadInt32 ();
buffer.WriteInt32 (symbols.code_size);
local_var_token = ReadToken ();
if (local_var_token.RID > 0) {
var variables = symbols.variables = ReadVariables (local_var_token);
buffer.WriteUInt32 (variables != null
? writer.GetStandAloneSignature (symbols.variables).ToUInt32 ()
: 0);
} else
buffer.WriteUInt32 (0);
PatchRawCode (buffer, symbols.code_size, writer);
if ((flags & 0x8) != 0)
PatchRawSection (buffer, writer.metadata);
}
示例10: GetString
public string GetString (MetadataToken token)
{
return reader.image.UserStringHeap.Read (token.RID);
}
示例11: WriteMetadataToken
void WriteMetadataToken (MetadataToken token)
{
WriteUInt32 (token.ToUInt32 ());
}
示例12: MoveNext
public bool MoveNext()
{
int nextRid = m_currentRid + 1;
if (nextRid >= m_endRid) {
if (m_tables == null) {
throw new ObjectDisposedException("MetadataTableEnumerator");
}
return false;
}
m_currentRid = nextRid;
switch (m_indirection) {
case EnumerationIndirection.Method:
m_currentToken = m_tables.m_import.MethodPtrTable.GetMethodFor(m_currentRid);
break;
case EnumerationIndirection.Field:
m_currentToken = m_tables.m_import.FieldPtrTable.GetFieldFor(m_currentRid);
break;
case EnumerationIndirection.Property:
m_currentToken = m_tables.m_import.PropertyPtrTable.GetPropertyFor(m_currentRid);
break;
case EnumerationIndirection.Event:
m_currentToken = m_tables.m_import.EventPtrTable.GetEventFor(m_currentRid);
break;
case EnumerationIndirection.Param:
m_currentToken = m_tables.m_import.ParamPtrTable.GetParamFor(m_currentRid);
break;
default:
m_currentToken = new MetadataToken(m_type, (uint)m_currentRid);
break;
}
return true;
}
示例13: SetGenericConstraintMapping
public void SetGenericConstraintMapping (uint gp_rid, MetadataToken [] mapping)
{
GenericConstraints [gp_rid] = mapping;
}
示例14: TryGetGenericConstraintMapping
public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out MetadataToken [] mapping)
{
return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping);
}
示例15: SetInterfaceMapping
public void SetInterfaceMapping (uint type_rid, MetadataToken [] mapping)
{
Interfaces [type_rid] = mapping;
}