Example #1
0
        protected NuGenCustomModifier ReadCustomModifier(ref IntPtr signatureBlob)
        {
            NuGenCustomModifier result = new NuGenCustomModifier();

            uint data;

            NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data));

            result.Modifier = (CorElementType)data;
            NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data));
            result.TypeToken = NuGenSignatureCompression.CorSigUncompressToken(data);

            return(result);
        }
Example #2
0
        protected NuGenTypeSignatureItem ReadType(ref IntPtr signatureBlob)
        {
            NuGenTypeSignatureItem result = new NuGenTypeSignatureItem();

            uint data;

            NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data));

            result.ElementType = (CorElementType)data;
            switch (result.ElementType)
            {
            case CorElementType.ELEMENT_TYPE_VALUETYPE:
            case CorElementType.ELEMENT_TYPE_CLASS:
                NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data));
                result.Token = NuGenSignatureCompression.CorSigUncompressToken(data);
                break;

            case CorElementType.ELEMENT_TYPE_SZARRAY:
            case CorElementType.ELEMENT_TYPE_PTR:
                CorElementType             elementType     = CorElementType.ELEMENT_TYPE_BYREF;
                bool                       addElementType  = false;
                List <NuGenCustomModifier> customModifiers = new List <NuGenCustomModifier>();

                do
                {
                    if (addElementType)
                    {
                        NuGenCustomModifier customModifier = ReadCustomModifier(ref signatureBlob);
                        customModifiers.Add(customModifier);
                    }

                    addElementType = true;
                    NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data);
                    elementType = (CorElementType)data;
                } while (elementType == CorElementType.ELEMENT_TYPE_CMOD_OPT || elementType == CorElementType.ELEMENT_TYPE_CMOD_REQD);

                NuGenBaseSignatureItem nextItem = ReadSignatureItem(ref signatureBlob);
                result.NextItem = nextItem;

                if (nextItem.GetType() == typeof(NuGenTypeSignatureItem) && customModifiers.Count > 0)
                {
                    ((NuGenTypeSignatureItem)nextItem).CustomModifiers = customModifiers;
                }
                break;
            }

            return(result);
        }