GetGlobalizationResourceBytePtr() static private méthode

static private GetGlobalizationResourceBytePtr ( Assembly assembly, String tableName ) : byte*
assembly System.Reflection.Assembly
tableName String
Résultat byte*
Exemple #1
0
        internal unsafe void InitializeBaseInfoTablePointers(String fileName, bool fromAssembly)
        {
            if (fromAssembly)
            {
                m_pDataFileStart = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(BaseInfoTable).Assembly, fileName);
            }
            else
            {
                this.memoryMapFile = new MemoryMapFile(fileName);

                if (this.memoryMapFile.FileSize == 0)
                {
                    m_valid = false;
                    return;
                }

                this.m_pDataFileStart = this.memoryMapFile.GetBytePtr();
            }
            EndianessHeader *pEndianHeader = (EndianessHeader *)m_pDataFileStart;

            // Set up pointer to the CultureTableHeader

#if BIGENDIAN
            BCLDebug.Assert(pEndianHeader->beOffset != 0, "Big-Endian data is expected.");
            m_pCultureHeader = (CultureTableHeader *)(m_pDataFileStart + pEndianHeader->beOffset);
#else
            BCLDebug.Assert(pEndianHeader->leOffset != 0, "Little-Endian data is expected.");
            m_pCultureHeader = (CultureTableHeader *)(m_pDataFileStart + pEndianHeader->leOffset);
#endif

            // Set up misc pointers and variables.
            // Different data items for calendar and culture, so they each have their own setting thingy.
            SetDataItemPointers();
        }
Exemple #2
0
        internal static unsafe void *GetNativeTextInfo(int cultureID)
        {
            // First, assume this culture does not has exceptions. I.e. we should use the default casingg table.
            // So we assign the native NativeTextInfo for the default casing table to it.
            void *pNativeTextInfo = m_pDefaultCasingTable;

            // Now, go thru the exception table to see if it has exception or not.
            for (int i = 0; i < m_exceptionCount; i++)
            {
                if (m_exceptionTable[i].langID == cultureID)
                {
                    // This culture has exceptions.
                    if (m_exceptionNativeTextInfo[i] == 0)
                    {
                        lock (InternalSyncObject) {
                            // Read the exception casing file.
                            if (m_pExceptionFile == null)
                            {
                                m_pExceptionFile = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(TextInfo).Assembly, CASING_EXCEPTIONS_FILE_NAME);
                            }
                            long tempPtr = (long)(InternalAllocateCasingTable(m_pExceptionFile, m_exceptionTable[i].exceptIndex));
                            System.Threading.Thread.MemoryBarrier();
                            m_exceptionNativeTextInfo[i] = tempPtr;
                        }
                    }
                    pNativeTextInfo = (void *)m_exceptionNativeTextInfo[i];
                    break;
                }
            }
            return(pNativeTextInfo);
        }
Exemple #3
0
        ////////////////////////////////////////////////////////////////////////
        //
        //  Actions:
        //      This is the static ctor for TextInfo.  It does the following items:
        //      * Get the total count of cultures with exceptions.
        //      * Set up an exception index table so that we can check if a culture has exception.  If yes, which sub-table
        //        in the exception table file we should use for this culture.
        //      * Set up a cache for NativeTextInfo that we create for cultures with exceptions.
        //
        ////////////////////////////////////////////////////////////////////////

        static unsafe TextInfo()
        {
            //with AppDomains active, the static initializer is no longer good enough to ensure that only one
            //thread is ever in AllocateDefaultCasingTable at a given time.
            //We use InterlockedExchangePointer in the native side to ensure that only one instance of native CasingTable instance
            //is created per process.

            //We check if the table is already allocated in native, so we only need to synchronize
            //access in managed.
            byte *temp = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(TextInfo).Assembly, CASING_FILE_NAME);

            System.Threading.Thread.MemoryBarrier();
            m_pDataTable = temp;

            TextInfoDataHeader *pHeader = (TextInfoDataHeader *)m_pDataTable;

            m_exceptionCount = pHeader->exceptionCount;
            // Setup exception tables
            m_exceptionTable          = (ExceptionTableItem *)&(pHeader->exceptionLangId);
            m_exceptionNativeTextInfo = new long[m_exceptionCount];

            // Create the native NativeTextInfo for the default linguistic casing table.
            m_pDefaultCasingTable = AllocateDefaultCasingTable(m_pDataTable);

            BCLDebug.Assert(m_pDataTable != null, "Error in reading the table.");
            BCLDebug.Assert(m_pDefaultCasingTable != null, "m_pDefaultCasingTable != null");
        }
        private unsafe static bool InitTable()
        {
            byte *globalizationResourceBytePtr = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, "charinfo.nlp");

            CharUnicodeInfo.UnicodeDataHeader *ptr = (CharUnicodeInfo.UnicodeDataHeader *)globalizationResourceBytePtr;
            CharUnicodeInfo.s_pCategoryLevel1Index = (ushort *)(globalizationResourceBytePtr + ptr->OffsetToCategoriesIndex);
            CharUnicodeInfo.s_pCategoriesValue     = globalizationResourceBytePtr + ptr->OffsetToCategoriesValue;
            CharUnicodeInfo.s_pNumericLevel1Index  = (ushort *)(globalizationResourceBytePtr + ptr->OffsetToNumbericIndex);
            CharUnicodeInfo.s_pNumericValues       = globalizationResourceBytePtr + ptr->OffsetToNumbericValue;
            CharUnicodeInfo.s_pDigitValues         = (CharUnicodeInfo.DigitValues *)(globalizationResourceBytePtr + ptr->OffsetToDigitValue);
            return(true);
        }
Exemple #5
0
        //We need to allocate the underlying table that provides us with the information that we
        //use.  We allocate this once in the class initializer and then we don't need to worry
        //about it again.
        //
        unsafe static CharUnicodeInfo()
        {
            m_pDataTable = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, UNICODE_INFO_FILE_NAME);
            UnicodeDataHeader *mainHeader = (UnicodeDataHeader *)m_pDataTable;

            // Set up the native pointer to different part of the tables.
            m_pCategoryLevel1Index = (ushort *)(m_pDataTable + mainHeader->OffsetToCategoriesIndex);
            m_pCategoriesValue     = (byte *)(m_pDataTable + mainHeader->OffsetToCategoriesValue);
            m_pNumericLevel1Index  = (ushort *)(m_pDataTable + mainHeader->OffsetToNumbericIndex);
            m_pNumericValues       = (byte *)(m_pDataTable + mainHeader->OffsetToNumbericValue);
            m_pDigitValues         = (DigitValues *)(m_pDataTable + mainHeader->OffsetToDigitValue);

            // Go to native side to make sure the native CharacterInfoTable pointer in the native side is initialized.
            nativeInitTable(m_pDataTable);
        }
Exemple #6
0
        unsafe static bool InitTable()
        {
            // Go to native side and get pointer to the native table
            byte *pDataTable = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, UNICODE_INFO_FILE_NAME);

            UnicodeDataHeader *mainHeader = (UnicodeDataHeader *)pDataTable;

            // Set up the native pointer to different part of the tables.
            s_pCategoryLevel1Index = (ushort *)(pDataTable + EndianSwap(mainHeader->OffsetToCategoriesIndex));
            s_pCategoriesValue     = (byte *)(pDataTable + EndianSwap(mainHeader->OffsetToCategoriesValue));
            s_pNumericLevel1Index  = (ushort *)(pDataTable + EndianSwap(mainHeader->OffsetToNumbericIndex));
            s_pNumericValues       = (byte *)(pDataTable + EndianSwap(mainHeader->OffsetToNumbericValue));
            s_pDigitValues         = (DigitValues *)(pDataTable + EndianSwap(mainHeader->OffsetToDigitValue));

            return(true);
        }
Exemple #7
0
        internal unsafe void InitializeBaseInfoTablePointers(string fileName, bool fromAssembly)
        {
            if (fromAssembly)
            {
                this.m_pDataFileStart = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(BaseInfoTable).Assembly, fileName);
            }
            else
            {
                this.memoryMapFile = new AgileSafeNativeMemoryHandle(fileName);
                if (this.memoryMapFile.FileSize == 0L)
                {
                    this.m_valid = false;
                    return;
                }
                this.m_pDataFileStart = this.memoryMapFile.GetBytePtr();
            }
            EndianessHeader *pDataFileStart = (EndianessHeader *)this.m_pDataFileStart;

            this.m_pCultureHeader = (CultureTableHeader *)(this.m_pDataFileStart + pDataFileStart->leOffset);
            this.SetDataItemPointers();
        }
        private static unsafe bool InitTable()
        {
            byte *globalizationResourceBytePtr;

            CharUnicodeInfo.UnicodeDataHeader *unicodeDataHeaderPtr = (CharUnicodeInfo.UnicodeDataHeader *)(globalizationResourceBytePtr = GlobalizationAssembly.GetGlobalizationResourceBytePtr(typeof(CharUnicodeInfo).Assembly, "charinfo.nlp"));
            IntPtr num1 = (IntPtr)unicodeDataHeaderPtr->OffsetToCategoriesIndex;

            CharUnicodeInfo.s_pCategoryLevel1Index = (ushort *)(globalizationResourceBytePtr + num1.ToInt64());
            IntPtr num2 = (IntPtr)unicodeDataHeaderPtr->OffsetToCategoriesValue;

            CharUnicodeInfo.s_pCategoriesValue = globalizationResourceBytePtr + num2.ToInt64();
            IntPtr num3 = (IntPtr)unicodeDataHeaderPtr->OffsetToNumbericIndex;

            CharUnicodeInfo.s_pNumericLevel1Index = (ushort *)(globalizationResourceBytePtr + num3.ToInt64());
            IntPtr num4 = (IntPtr)unicodeDataHeaderPtr->OffsetToNumbericValue;

            CharUnicodeInfo.s_pNumericValues = globalizationResourceBytePtr + num4.ToInt64();
            IntPtr num5 = (IntPtr)unicodeDataHeaderPtr->OffsetToDigitValue;

            CharUnicodeInfo.s_pDigitValues = (CharUnicodeInfo.DigitValues *)(globalizationResourceBytePtr + num5.ToInt64());
            return(true);
        }