예제 #1
0
        internal MetadataTableEnumerator(MetadataRecord parent, MetadataTokenType type)
        {
            Debug.Assert(parent.IsValid);

            m_type = type;
            m_tables = parent.m_tables;

            int start, count;
            m_indirection = parent.m_tables.m_import.GetEnumeratorRange(type, parent.Token, out start, out count);

            m_startRid = start;
            m_endRid = start + count;
            m_currentRid = start - 1;
        }
예제 #2
0
        internal EnumerationIndirection GetEnumeratorRange(MetadataTokenType type, MetadataToken parent, out int startRid, out int count) {
            Debug.Assert(IsValidToken(parent));

            switch (type) {
                case MetadataTokenType.MethodDef:
                    if (parent.IsNull) {
                        count = MethodTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsTypeDef);
                        startRid = GetMethodRange(parent.Rid, out count);
                    }
                    return UseParamPtrTable ? EnumerationIndirection.Method : EnumerationIndirection.None;

                case MetadataTokenType.Property:
                    if (parent.IsNull) {
                        count = PropertyTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsTypeDef);
                        startRid = GetPropertyRange(parent.Rid, out count);
                    }
                    return UsePropertyPtrTable ? EnumerationIndirection.Property : EnumerationIndirection.None;

                case MetadataTokenType.Event:
                    if (parent.IsNull) {
                        count = EventTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsTypeDef);
                        startRid = GetEventRange(parent.Rid, out count);
                    }
                    return UseEventPtrTable ? EnumerationIndirection.Event : EnumerationIndirection.None;

                case MetadataTokenType.FieldDef:
                    if (parent.IsNull) {
                        count = FieldTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsTypeDef);
                        startRid = GetFieldRange(parent.Rid, out count);
                    }
                    return UseFieldPtrTable ? EnumerationIndirection.Field : EnumerationIndirection.None;

                case MetadataTokenType.ParamDef:
                    if (parent.IsNull) {
                        count = ParamTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsMethodDef);
                        startRid = GetParamRange(parent.Rid, out count);
                    }
                    return UseParamPtrTable ? EnumerationIndirection.Param : EnumerationIndirection.None;

                case MetadataTokenType.CustomAttribute:
                    if (parent.IsNull) {
                        count = CustomAttributeTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        startRid = CustomAttributeTable.FindCustomAttributesForToken(parent, out count);
                    }
                    return EnumerationIndirection.None;

                case MetadataTokenType.InterfaceImpl:
                    if (parent.IsNull) {
                        count = InterfaceImplTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsTypeDef);
                        startRid = InterfaceImplTable.FindInterfaceImplForType(parent.Rid, out count);
                    }
                    return EnumerationIndirection.None;

                case MetadataTokenType.GenericPar:
                    if (parent.IsNull) {
                        count = GenericParamTable.NumberOfRows;
                        startRid = 1;
                    } else if (parent.IsTypeDef) {
                        startRid = GenericParamTable.FindGenericParametersForType(parent.Rid, out count);
                    } else {
                        Debug.Assert(parent.IsMethodDef);
                        startRid = GenericParamTable.FindGenericParametersForMethod(parent.Rid, out count);
                    }
                    return EnumerationIndirection.None;

                case MetadataTokenType.GenericParamConstraint:
                    if (parent.IsNull) {
                        count = GenericParamConstraintTable.NumberOfRows;
                        startRid = 1;
                    } else {
                        Debug.Assert(parent.IsGenericParam);
                        startRid = GenericParamConstraintTable.FindConstraintForGenericParam(parent.Rid, out count);
                    }
                    return EnumerationIndirection.None;

                case MetadataTokenType.AssemblyRef:
                case MetadataTokenType.ModuleRef:
                case MetadataTokenType.File:
                case MetadataTokenType.TypeDef:
                case MetadataTokenType.TypeSpec:
                case MetadataTokenType.TypeRef:
                case MetadataTokenType.NestedClass:
                case MetadataTokenType.ExportedType:
                case MetadataTokenType.MethodSpec:
                case MetadataTokenType.MemberRef:
                case MetadataTokenType.Signature:
                case MetadataTokenType.ManifestResource:
                    Debug.Assert(parent.IsNull);
                    count = _tableRowCounts[(int)type >> 24];
                    startRid = 1;
                    return EnumerationIndirection.None;

                default:
                    Debug.Assert(false);
                    throw new InvalidOperationException();
            }
        }
예제 #3
0
 [System.Security.SecurityCritical]  // auto-generated
 public unsafe void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result) 
 { 
     _Enum(m_metadataImport2, (int)type, parent, out result);
 }
예제 #4
0
 // helper to get number of rows in MethodDef table.
 int GetTokenRows(MetadataTokenType tableIndex)
 {
     IMetadataTables table = (IMetadataTables)this.m_importer;
     uint tbl = (uint)tableIndex >> 24;
     uint cbRow;
     uint cRows;
     uint cColumns;
     uint iKey;
     string name;
     table.GetTableInfo(tbl, out cbRow, out cRows, out cColumns, out iKey, out name);
     return (int)cRows;
 }
예제 #5
0
 public MetadataToken(MetadataTokenType mdType, int rid)
 {
     this.value = (int)((uint)mdType + (uint)rid);
     Debug.Assert(this.Type == mdType);
     Debug.Assert(this.Index == rid);
 }
예제 #6
0
 public unsafe void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result)
 {
     _Enum(m_metadataImport2, (int)type, parent, out result);
 }
예제 #7
0
 protected int ReadCompressedMetadataToken(MetadataTokenType type)
 {
     return((int)(this.ReadCompressedUInt() | (uint)type));
 }
예제 #8
0
 internal MetadataToken(MetadataTokenType type, uint rowId)
 {
     m_value = (int)type | (int)(rowId & 0x00ffffff);
 }
예제 #9
0
 internal MetadataTableView(MetadataRecord parent, MetadataTokenType type)
 {
     m_type   = type;
     m_parent = parent;
 }
예제 #10
0
 private MetadataTableType Convert(MetadataTokenType tokenType)
 {
     return((MetadataTableType)(byte)((uint)tokenType >> 24));
 }