We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- namespace System.Globalization
- {
- using System;
- using System.Text;
- using System.Threading;
- using System.Runtime.InteropServices;
- using System.Runtime.CompilerServices;
- using System.Runtime.Serialization;
- using System.Security.Permissions;
-
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class TextInfo : ICloneable, IDeserializationCallback
- {
-
-
-
-
-
-
-
-
-
- [OptionalField(VersionAdded = 2)]
- private string m_listSeparator;
-
- [OptionalField(VersionAdded = 2)]
- private bool m_isReadOnly = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [NonSerialized()]
- private int m_textInfoID;
- [NonSerialized()]
- private string m_name = null;
- [NonSerialized()]
- private CultureTableRecord m_cultureTableRecord;
- [NonSerialized()]
- private TextInfo m_casingTextInfo;
-
-
-
-
-
-
- [NonSerialized()]
- unsafe private void* m_pNativeTextInfo;
- unsafe private static void* m_pInvariantNativeTextInfo;
- unsafe private static void* m_pDefaultCasingTable;
-
-
-
- private const string CASING_FILE_NAME = "l_intl.nlp";
-
- private const string CASING_EXCEPTIONS_FILE_NAME = "l_except.nlp";
-
-
-
-
- [StructLayout(LayoutKind.Explicit)]
- unsafe internal struct TextInfoDataHeader
- {
- [FieldOffset(0)]
- internal char TableName;
-
- [FieldOffset(32)]
- internal ushort version;
-
- [FieldOffset(40)]
- internal uint OffsetToUpperCasingTable;
-
- [FieldOffset(44)]
- internal uint OffsetToLowerCasingTable;
-
- [FieldOffset(48)]
- internal uint OffsetToTitleCaseTable;
-
- [FieldOffset(52)]
- internal uint PlaneOffset;
-
-
- [FieldOffset(180)]
- internal ushort exceptionCount;
- [FieldOffset(182)]
- internal ushort exceptionLangId;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- internal struct ExceptionTableItem
- {
- internal ushort langID;
-
- internal ushort exceptIndex;
-
- }
-
-
-
- unsafe static byte* m_pDataTable;
-
- static int m_exceptionCount;
-
-
- unsafe static ExceptionTableItem* m_exceptionTable;
-
-
- unsafe static byte* m_pExceptionFile;
-
-
-
-
- unsafe static long[] m_exceptionNativeTextInfo;
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
- unsafe static TextInfo()
- {
-
-
-
-
-
-
-
- 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;
-
- m_exceptionTable = (ExceptionTableItem*)&(pHeader->exceptionLangId);
- m_exceptionNativeTextInfo = new long[m_exceptionCount];
-
-
- m_pDefaultCasingTable = AllocateDefaultCasingTable(m_pDataTable);
-
- BCLDebug.Assert(m_pDataTable != null, "Error in reading the table.");
- BCLDebug.Assert(m_pDefaultCasingTable != null, "m_pDefaultCasingTable != null");
- }
-
-
- private static object s_InternalSyncObject;
- private static object InternalSyncObject {
- get {
- if (s_InternalSyncObject == null) {
- object o = new object();
- Interlocked.CompareExchange(ref s_InternalSyncObject, o, null);
- }
- return s_InternalSyncObject;
- }
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
- unsafe internal TextInfo(CultureTableRecord table)
- {
- this.m_cultureTableRecord = table;
- this.m_textInfoID = this.m_cultureTableRecord.ITEXTINFO;
-
- if (table.IsSynthetic) {
-
-
-
-
-
-
- m_pNativeTextInfo = InvariantNativeTextInfo;
- }
- else {
- this.m_pNativeTextInfo = GetNativeTextInfo(this.m_textInfoID);
- }
- }
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
- unsafe static internal void* InvariantNativeTextInfo {
- get {
- if (m_pInvariantNativeTextInfo == null) {
- lock (InternalSyncObject) {
- if (m_pInvariantNativeTextInfo == null) {
- m_pInvariantNativeTextInfo = GetNativeTextInfo(CultureInfo.LOCALE_INVARIANT);
- }
- }
- }
- BCLDebug.Assert(m_pInvariantNativeTextInfo != null, "TextInfo.InvariantNativeTextInfo: m_pInvariantNativeTextInfo != null");
- return (m_pInvariantNativeTextInfo);
- }
- }
-
- #region Serialization
-
-
-
- [OptionalField(VersionAdded = 2)]
- private string customCultureName;
-
-
- internal int m_nDataItem;
- internal bool m_useUserOverride;
- internal int m_win32LangID;
-
-
- [OnDeserializing()]
- private void OnDeserializing(StreamingContext ctx)
- {
- m_cultureTableRecord = null;
- m_win32LangID = 0;
- }
-
- unsafe private void OnDeserialized()
- {
-
- if (m_cultureTableRecord == null) {
- if (m_win32LangID == 0) {
- m_win32LangID = CultureTableRecord.IdFromEverettDataItem(m_nDataItem);
- }
-
- if (customCultureName != null) {
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(customCultureName, m_useUserOverride);
- }
- else {
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(m_win32LangID, m_useUserOverride);
- }
-
- m_textInfoID = m_cultureTableRecord.ITEXTINFO;
-
- if (m_cultureTableRecord.IsSynthetic) {
-
- m_pNativeTextInfo = InvariantNativeTextInfo;
- }
- else {
- m_pNativeTextInfo = GetNativeTextInfo(m_textInfoID);
- }
- }
- }
-
-
- [OnDeserialized()]
- private void OnDeserialized(StreamingContext ctx)
- {
- OnDeserialized();
- }
-
- [OnSerializing()]
- private void OnSerializing(StreamingContext ctx)
- {
- m_nDataItem = m_cultureTableRecord.EverettDataItem();
- m_useUserOverride = m_cultureTableRecord.UseUserOverride;
-
- if (CultureTableRecord.IsCustomCultureId(m_cultureTableRecord.CultureID)) {
- customCultureName = m_cultureTableRecord.SNAME;
- m_win32LangID = m_textInfoID;
- }
- else {
- customCultureName = null;
- m_win32LangID = m_cultureTableRecord.CultureID;
- }
-
- }
-
- #endregion Serialization
-
-
- unsafe static internal void* GetNativeTextInfo(int cultureID)
- {
- }
-
-
-
-
- void* pNativeTextInfo = m_pDefaultCasingTable;
- }
- }