_GetUserString() private method

private _GetUserString ( IntPtr scope, MetadataArgs &skipAddresses, int mdToken, void name, int &length ) : void
scope System.IntPtr
skipAddresses MetadataArgs
mdToken int
name void
length int
return void
Exemplo n.º 1
0
        public unsafe string GetUserString(int mdToken)
        {
            void *voidPtr;
            int   length;

            MetadataImport._GetUserString(this.m_metadataImport2, mdToken, &voidPtr, out length);
            if ((IntPtr)voidPtr == IntPtr.Zero)
            {
                return((string)null);
            }
            char[] chArray = new char[length];
            for (int index = 0; index < length; ++index)
            {
                chArray[index] = (char)*(ushort *)((IntPtr)voidPtr + (IntPtr)index * 2);
            }
            return(new string(chArray));
        }
        public unsafe string GetUserString(int mdToken)
        {
            void *ptr;
            int   num;

            MetadataImport._GetUserString(this.m_metadataImport2, mdToken, &ptr, out num);
            if (ptr == null)
            {
                return(null);
            }
            char[] array = new char[num];
            for (int i = 0; i < num; i++)
            {
                array[i] = (char)Marshal.ReadInt16((IntPtr)((void *)((byte *)ptr + (IntPtr)i * 2)));
            }
            return(new string(array));
        }