System.Globalization.GlobalizationAssembly.GetGlobalizationResourceBytePtr C# (CSharp) Method

GetGlobalizationResourceBytePtr() static private method

static private GetGlobalizationResourceBytePtr ( Assembly assembly, String tableName ) : byte*
assembly System.Reflection.Assembly
tableName String
return byte*
        internal unsafe static byte* GetGlobalizationResourceBytePtr(Assembly assembly, String tableName) {
            BCLDebug.Assert(assembly != null, "assembly can not be null.  This should be generally the mscorlib.dll assembly.");
            BCLDebug.Assert(tableName != null, "table name can not be null");
            
            Stream stream = assembly.GetManifestResourceStream(tableName);
            UnmanagedMemoryStream bytesStream = stream as UnmanagedMemoryStream;
            if (bytesStream != null) {
                byte* bytes = bytesStream.PositionPointer;
                if (bytes != null) {
                    return (bytes);
                }
            }
            
            BCLDebug.Assert(
                    false, 
                    String.Format(
                        CultureInfo.CurrentCulture,
                        "Didn't get the resource table {0} for System.Globalization from {1}", 
                        tableName, 
                        assembly));
            // We can not continue if we can't get the resource.
            throw new ExecutionEngineException();
        }

Usage Example

Example #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();
        }
All Usage Examples Of System.Globalization.GlobalizationAssembly::GetGlobalizationResourceBytePtr