示例#1
0
        IField ResolveField_NoLock(Int32 position)
        {
            this.Stream.Position = position;

            InlineOperand operand = new InlineOperand(this.Reader);

            if (operand.IsToken)
            {
                MDToken token = new MDToken(operand.Token);
                return(this.Module.ResolveField(token.Rid));
            }
            else
            {
                FieldData     data          = operand.Data as FieldData;
                ITypeDefOrRef declaringType = this.ResolveType_NoLock(data.FieldType.Position);
                if (declaringType == null)
                {
                    throw new Exception("[ResolveField_NoLock] Unable to resolve type as TypeDef or TypeRef");
                }

                NameResolver nameResolver = new NameResolver(this.Module);
                IField       field        = nameResolver.ResolveField(declaringType, data.Name);
                if (field == null)
                {
                    throw new Exception(String.Format(
                                            "[ResolveField_NoLock] Unable to resolve field: DeclaringType={0}, Field={1}",
                                            declaringType.ReflectionFullName, data.Name));
                }

                return(field);
            }
        }