Пример #1
0
        public FieldInfo GetMetaInfo()
        {
            if ((state & StateFlags.PendingMetaInflate) != 0)
            {
                var decl_meta = DeclaringType.GetMetaInfo();
                if (DeclaringType.IsTypeBuilder)
                {
                    metaInfo = TypeBuilder.GetField(decl_meta, metaInfo);
                }
                else
                {
                    var orig_token = metaInfo.MetadataToken;
                    metaInfo = decl_meta.GetField(Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                    if (metaInfo.MetadataToken != orig_token)
                    {
                        throw new NotImplementedException("Resolved to wrong meta token");
                    }

                    // What a stupid API, does not work because field handle is imported
                    // metaInfo = FieldInfo.GetFieldFromHandle (metaInfo.FieldHandle, DeclaringType.MetaInfo.TypeHandle);
                }

                state &= ~StateFlags.PendingMetaInflate;
            }

            return(metaInfo);
        }