Пример #1
0
        DmdType[] CreateGenericParameters_COMThread()
        {
            reader.Dispatcher.VerifyAccess();
            var tokens = MDAPI.GetGenericParamTokens(reader.MetaDataImport, (uint)MetadataToken);

            if (tokens.Length == 0)
            {
                return(null);
            }
            var genericParams = new DmdType[tokens.Length];

            for (int i = 0; i < genericParams.Length; i++)
            {
                uint token  = tokens[i];
                uint rid    = token & 0x00FFFFFF;
                var  gpName = MDAPI.GetGenericParamName(reader.MetaDataImport, token) ?? string.Empty;
                if (!MDAPI.GetGenericParamNumAndAttrs(reader.MetaDataImport, token, out var gpNumber, out var gpAttrs))
                {
                    return(null);
                }
                var gpType = new DmdGenericParameterTypeCOMD(reader, rid, this, gpName, gpNumber, gpAttrs, null);
                genericParams[i] = gpType;
            }
            return(genericParams);
        }
Пример #2
0
        void InitGenericParams_NoLock()
        {
            var  mdi2  = readerModule.MetaDataImport2;
            uint token = OriginalToken.Raw;

            genericParameters?.Clear();

            var itemTokens = MDAPI.GetGenericParamTokens(mdi2, token);
            var newItems   = new MemberInfo <CorGenericParam> [itemTokens.Length];

            for (int i = 0; i < itemTokens.Length; i++)
            {
                uint itemRid = itemTokens[i] & 0x00FFFFFF;
                newItems[i] = readerModule.Register(new CorGenericParam(readerModule, itemRid, this), cmd => cmd.Initialize());
            }

            genericParameters = new LazyList <GenericParam>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
        }
Пример #3
0
        public static List <TokenAndName> GetGenericParameterNames(IMetaDataImport mdi, uint token)
        {
            var gpTokens = MDAPI.GetGenericParamTokens(mdi as IMetaDataImport2, token);
            var list     = new List <TokenAndName>(gpTokens.Length);

            var mdi2 = mdi as IMetaDataImport2;

            if (mdi2 == null)
            {
                return(list);
            }

            foreach (var gpTok in gpTokens)
            {
                var name = MDAPI.GetGenericParamName(mdi as IMetaDataImport2, gpTok);
                list.Add(new TokenAndName(name ?? string.Empty, gpTok));
            }

            return(list);
        }
Пример #4
0
 public static int GetCountGenericParameters(IMetaDataImport mdi, uint token) => MDAPI.GetGenericParamTokens(mdi as IMetaDataImport2, token).Length;