• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MetadataToken类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MetadataToken的典型用法代码示例。如果您正苦于以下问题:C# MetadataToken类的具体用法?C# MetadataToken怎么用?C# MetadataToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetadataToken类属于命名空间,在下文中一共展示了MetadataToken类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 ();
        }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:31,代码来源:MdbWriter.cs


示例2: WriteToken

		void WriteToken (MetadataToken token)
		{
			if (token.RID == 0)
				m_codeWriter.Write (0);
			else
				m_codeWriter.Write (token.ToUInt ());
		}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:CodeWriter.cs


示例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;
        }
开发者ID:JerreS,项目名称:AsmResolver,代码行数:8,代码来源:IndexEncoder.cs


示例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);
        }
开发者ID:ttRevan,项目名称:cecil,代码行数:10,代码来源:AssemblyNameReference.cs


示例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;
     }
 }
开发者ID:GregRos,项目名称:Patchwork,代码行数:24,代码来源:Hacks.cs


示例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);
		}
开发者ID:nobled,项目名称:mono,代码行数:11,代码来源:StructureWriter.cs


示例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);
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:StructureWriter.cs


示例8: ModuleReference

 internal ModuleReference()
 {
     this.token = new MetadataToken (TokenType.ModuleRef);
 }
开发者ID:peterwald,项目名称:cecil,代码行数:4,代码来源:ModuleReference.cs


示例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);
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:22,代码来源:CodeReader.cs


示例10: GetString

		public string GetString (MetadataToken token)
		{
			return reader.image.UserStringHeap.Read (token.RID);
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:4,代码来源:CodeReader.cs


示例11: WriteMetadataToken

		void WriteMetadataToken (MetadataToken token)
		{
			WriteUInt32 (token.ToUInt32 ());
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:4,代码来源:CodeWriter.cs


示例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;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:41,代码来源:MetadataTableEnumerator.CCI.cs


示例13: SetGenericConstraintMapping

		public void SetGenericConstraintMapping (uint gp_rid, MetadataToken [] mapping)
		{
			GenericConstraints [gp_rid] = mapping;
		}
开发者ID:n017,项目名称:Confuser,代码行数:4,代码来源:MetadataSystem.cs


示例14: TryGetGenericConstraintMapping

		public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out MetadataToken [] mapping)
		{
			return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping);
		}
开发者ID:n017,项目名称:Confuser,代码行数:4,代码来源:MetadataSystem.cs


示例15: SetInterfaceMapping

		public void SetInterfaceMapping (uint type_rid, MetadataToken [] mapping)
		{
			Interfaces [type_rid] = mapping;
		}
开发者ID:n017,项目名称:Confuser,代码行数:4,代码来源:MetadataSystem.cs


示例16: TryGetInterfaceMapping

		public bool TryGetInterfaceMapping (TypeDefinition type, out MetadataToken [] mapping)
		{
			return Interfaces.TryGetValue (type.token.RID, out mapping);
		}
开发者ID:n017,项目名称:Confuser,代码行数:4,代码来源:MetadataSystem.cs


示例17: VisitTypeReferenceCollection

        public override void VisitTypeReferenceCollection(TypeReferenceCollection refs)
        {
            ArrayList orderedTypeRefs = new ArrayList (refs.Count);
            foreach (TypeReference tr in refs)
                orderedTypeRefs.Add (tr);

            orderedTypeRefs.Sort (TableComparers.TypeRef.Instance);

            TypeRefTable trTable = m_tableWriter.GetTypeRefTable ();
            foreach (TypeReference t in orderedTypeRefs) {
                MetadataToken scope;

                if (t.Module.Assembly != m_mod.Assembly)
                    throw new ReflectionException ("A type as not been correctly imported");

                if (t.Scope == null)
                    continue;

                if (t.DeclaringType != null)
                    scope = new MetadataToken (TokenType.TypeRef, GetRidFor (t.DeclaringType));
                else if (t.Scope is AssemblyNameReference)
                    scope = new MetadataToken (TokenType.AssemblyRef,
                        GetRidFor ((AssemblyNameReference) t.Scope));
                else if (t.Scope is ModuleDefinition)
                    scope = new MetadataToken (TokenType.Module,
                        GetRidFor ((ModuleDefinition) t.Scope));
                else if (t.Scope is ModuleReference)
                    scope = new MetadataToken (TokenType.ModuleRef,
                        GetRidFor ((ModuleReference) t.Scope));
                else
                    scope = new MetadataToken (TokenType.ExportedType, 0);

                TypeRefRow trRow = m_rowWriter.CreateTypeRefRow (
                    scope,
                    m_mdWriter.AddString (t.Name),
                    m_mdWriter.AddString (t.Namespace));

                trTable.Rows.Add (trRow);
                t.MetadataToken = new MetadataToken (TokenType.TypeRef, (uint) trTable.Rows.Count);
            }
        }
开发者ID:leftouterjoin,项目名称:loj-prj1,代码行数:41,代码来源:ReflectionWriter.cs


示例18: VisitCustomAttributeCollection

        public override void VisitCustomAttributeCollection(CustomAttributeCollection customAttrs)
        {
            if (customAttrs.Count == 0)
                return;

            CustomAttributeTable caTable = m_tableWriter.GetCustomAttributeTable ();
            foreach (CustomAttribute ca in customAttrs) {
                MetadataToken parent;
                if (customAttrs.Container is AssemblyDefinition)
                    parent = new MetadataToken (TokenType.Assembly, 1);
                else if (customAttrs.Container is ModuleDefinition)
                    parent = new MetadataToken (TokenType.Module, 1);
                else if (customAttrs.Container is IMetadataTokenProvider)
                    parent = (customAttrs.Container as IMetadataTokenProvider).MetadataToken;
                else
                    throw new ReflectionException ("Unknown Custom Attribute parent");

                uint value = ca.IsReadable ?
                    m_sigWriter.AddCustomAttribute (GetCustomAttributeSig (ca), ca.Constructor) :
                    m_mdWriter.AddBlob (m_mod.GetAsByteArray (ca));
                CustomAttributeRow caRow = m_rowWriter.CreateCustomAttributeRow (
                    parent,
                    ca.Constructor.MetadataToken,
                    value);

                caTable.Rows.Add (caRow);
            }
        }
开发者ID:leftouterjoin,项目名称:loj-prj1,代码行数:28,代码来源:ReflectionWriter.cs


示例19: Reset

 public void Reset()
 {
     m_currentRid = m_startRid;
     m_currentToken = default(MetadataToken);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:5,代码来源:MetadataTableEnumerator.CCI.cs


示例20: TryGetOverrideMapping

		public bool TryGetOverrideMapping (MethodDefinition method, out MetadataToken [] mapping)
		{
			return Overrides.TryGetValue (method.token.RID, out mapping);
		}
开发者ID:n017,项目名称:Confuser,代码行数:4,代码来源:MetadataSystem.cs



注:本文中的MetadataToken类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MetadataType类代码示例发布时间:2022-05-24
下一篇:
C# MetadataSource类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap