The Labs \ Source Viewer \ SSCLI \ System.Globalization \ CodePageDataItem

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace System.Globalization
  16. {
  17.     using System.Text;
  18.     using System.Runtime.Remoting;
  19.     using System;
  20.    
  21.     //
  22.     // Data item for EncodingTable. Along with EncodingTable, they are used by
  23.     // System.Text.Encoding.
  24.     //
  25.     // This class stores a pointer to the internal data and the index into that data
  26.     // where our required information is found. We load the code page, flags and uiFamilyCodePage
  27.     // immediately because they don't require creating an object. Creating any of the string
  28.     // names is delayed until somebody actually asks for them and the names are then cached.
  29.    
  30.     [Serializable()]
  31.     internal class CodePageDataItem
  32.     {
  33.         internal int m_dataIndex;
  34.         internal int m_codePage;
  35.         internal int m_uiFamilyCodePage;
  36.         internal string m_webName;
  37.         internal string m_headerName;
  38.         internal string m_bodyName;
  39.         internal string m_description;
  40.         internal uint m_flags;
  41.        
  42.         unsafe internal CodePageDataItem(int dataIndex)
  43.         {
  44.             m_dataIndex = dataIndex;
  45.             m_codePage = 0;
  46.             m_uiFamilyCodePage = EncodingTable.codePageDataPtr[dataIndex].uiFamilyCodePage;
  47.             m_webName = null;
  48.             m_headerName = null;
  49.             m_bodyName = null;
  50.             m_description = null;
  51.             m_flags = EncodingTable.codePageDataPtr[dataIndex].flags;
  52.         }
  53.        
  54.         unsafe public virtual string WebName {
  55.             get {
  56.                 if (m_webName == null) {
  57.                     m_webName = new string(EncodingTable.codePageDataPtr[m_dataIndex].webName);
  58.                 }
  59.                 return m_webName;
  60.             }
  61.         }
  62.        
  63.         public virtual int UIFamilyCodePage {
  64.             get { return m_uiFamilyCodePage; }
  65.         }
  66.        
  67.         unsafe public virtual string HeaderName {
  68.             get {
  69.                 if (m_headerName == null) {
  70.                     m_headerName = new string(EncodingTable.codePageDataPtr[m_dataIndex].headerName);
  71.                 }
  72.                 return m_headerName;
  73.             }
  74.         }
  75.        
  76.         unsafe public virtual string BodyName {
  77.             get {
  78.                 if (m_bodyName == null) {
  79.                     m_bodyName = new string(EncodingTable.codePageDataPtr[m_dataIndex].bodyName);
  80.                 }
  81.                 return m_bodyName;
  82.             }
  83.         }
  84.        
  85.         unsafe public virtual uint Flags {
  86.             get { return (m_flags); }
  87.         }
  88.     }
  89. }

Developer Fusion