Esempio n. 1
0
		public MetadataToken ExpandTypeDefRefOrSpecToken(uint pToken)
		{
			MetadataToken token = new MetadataToken();
			token.Table = (byte)(pToken & 0x03);
			switch (token.Table)
			{
				case 0: token.Table = MetadataTables.TypeDef; break;
				case 1: token.Table = MetadataTables.TypeRef; break;
				case 2: token.Table = MetadataTables.TypeSpec; break;
				default: return token;
			}
			uint index = pToken >> 2;
			if (index == 0) return token;
			--index;
			switch (token.Table)
			{
				case MetadataTables.TypeDef: token.Data = TypeDefTable[index]; break;
				case MetadataTables.TypeRef: token.Data = TypeRefTable[index]; break;
				case MetadataTables.TypeSpec: token.Data = TypeSpecTable[index]; break;
				default: break;
			}
			return token;
		}
Esempio n. 2
0
		public MetadataToken ExpandMetadataToken(uint pToken)
		{
			MetadataToken token = new MetadataToken();
			token.Table = (byte)(pToken >> 24);
			token.IsUserString = token.Table == MetadataTables.UserStrings;
			uint index = pToken & 0x00FFFFFF;
			if (index == 0) return token;
			if (token.IsUserString)
			{
				token.Data = ReadUserStringHeap((int)index);
				return token;
			}
			--index;
			switch (token.Table)
			{
				case MetadataTables.Module: token.Data = ModuleTable[index]; break;
				case MetadataTables.TypeRef: token.Data = TypeRefTable[index]; break;
				case MetadataTables.TypeDef: token.Data = TypeDefTable[index]; break;
				case MetadataTables.Field: token.Data = FieldTable[index]; break;
				case MetadataTables.MethodDef: token.Data = MethodDefTable[index]; break;
				case MetadataTables.Param: token.Data = ParamTable[index]; break;
				case MetadataTables.InterfaceImpl: token.Data = InterfaceImplTable[index]; break;
				case MetadataTables.MemberRef: token.Data = MemberRefTable[index]; break;
				case MetadataTables.Constant: token.Data = ConstantTable[index]; break;
				case MetadataTables.CustomAttribute: token.Data = CustomAttributeTable[index]; break;
				case MetadataTables.FieldMarshal: token.Data = FieldMarshalTable[index]; break;
				case MetadataTables.DeclSecurity: token.Data = DeclSecurityTable[index]; break;
				case MetadataTables.ClassLayout: token.Data = ClassLayoutTable[index]; break;
				case MetadataTables.FieldLayout: token.Data = FieldLayoutTable[index]; break;
				case MetadataTables.StandAloneSig: token.Data = StandAloneSigTable[index]; break;
				case MetadataTables.EventMap: token.Data = EventMapTable[index]; break;
				case MetadataTables.Event: token.Data = EventTable[index]; break;
				case MetadataTables.PropertyMap: token.Data = PropertyMapTable[index]; break;
				case MetadataTables.Property: token.Data = PropertyTable[index]; break;
				case MetadataTables.MethodSemantics: token.Data = MethodSemanticsTable[index]; break;
				case MetadataTables.MethodImpl: token.Data = MethodImplTable[index]; break;
				case MetadataTables.ModuleRef: token.Data = ModuleRefTable[index]; break;
				case MetadataTables.TypeSpec: token.Data = TypeSpecTable[index]; break;
				case MetadataTables.ImplMap: token.Data = ImplMapTable[index]; break;
				case MetadataTables.FieldRVA: token.Data = FieldRVATable[index]; break;
				case MetadataTables.Assembly: token.Data = AssemblyTable[index]; break;
				case MetadataTables.AssemblyProcessor: token.Data = AssemblyProcessorTable[index]; break;
				case MetadataTables.AssemblyOS: token.Data = AssemblyOSTable[index]; break;
				case MetadataTables.AssemblyRef: token.Data = AssemblyRefTable[index]; break;
				case MetadataTables.AssemblyRefProcessor: token.Data = AssemblyRefProcessorTable[index]; break;
				case MetadataTables.AssemblyRefOS: token.Data = AssemblyRefOSTable[index]; break;
				case MetadataTables.File: token.Data = FileTable[index]; break;
				case MetadataTables.ExportedType: token.Data = ExportedTypeTable[index]; break;
				case MetadataTables.ManifestResource: token.Data = ManifestResourceTable[index]; break;
				case MetadataTables.NestedClass: token.Data = NestedClassTable[index]; break;
				case MetadataTables.GenericParam: token.Data = GenericParamTable[index]; break;
				case MetadataTables.MethodSpec: token.Data = MethodSpecTable[index]; break;
				case MetadataTables.GenericParamConstraint: token.Data = GenericParamConstraintTable[index]; break;
				default: break;
			}
			return token;
		}