Esempio n. 1
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");
        }
Esempio n. 2
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");
        }