internal static unsafe CodePageDataItem GetCodePageDataItem(int codepage)
 {
     int num2;
     CodePageDataItem item = (CodePageDataItem) hashByCodePage[codepage];
     if (item != null)
     {
         return item;
     }
     for (int i = 0; (num2 = codePageDataPtr[i].codePage) != 0; i++)
     {
         if (num2 == codepage)
         {
             item = new CodePageDataItem(i);
             hashByCodePage[codepage] = item;
             return item;
         }
     }
     return null;
 }
 private void OnSerializing(StreamingContext ctx)
 {
     this.dataItem = null;
 }
 internal void OnDeserialized()
 {
     if ((this.encoderFallback == null) || (this.decoderFallback == null))
     {
         this.m_deserializedFromEverett = true;
         this.SetDefaultFallbacks();
     }
     this.dataItem = null;
 }
 private void GetDataItem()
 {
     if (this.dataItem == null)
     {
         this.dataItem = EncodingTable.GetCodePageDataItem(this.m_codePage);
         if (this.dataItem == null)
         {
             throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoCodepageData", new object[] { this.m_codePage }));
         }
     }
 }
 internal void DeserializeEncoding(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.m_codePage = (int) info.GetValue("m_codePage", typeof(int));
     this.dataItem = null;
     try
     {
         this.m_isReadOnly = (bool) info.GetValue("m_isReadOnly", typeof(bool));
         this.encoderFallback = (System.Text.EncoderFallback) info.GetValue("encoderFallback", typeof(System.Text.EncoderFallback));
         this.decoderFallback = (System.Text.DecoderFallback) info.GetValue("decoderFallback", typeof(System.Text.DecoderFallback));
     }
     catch (SerializationException)
     {
         this.m_deserializedFromEverett = true;
         this.m_isReadOnly = true;
         this.SetDefaultFallbacks();
     }
 }
示例#6
0
 private void GetDataItem() {
     if (dataItem==null) {
         dataItem = EncodingTable.GetCodePageDataItem(m_codePage);
         if(dataItem==null) {
             throw new NotSupportedException(String.Format(Environment.GetResourceString("NotSupported_NoCodepageData"), m_codePage));
         }
     }
 }
示例#7
0
        // the following two methods are used for the inherited classes which implemented ISerializable
        // Deserialization Helper
        internal void DeserializeEncoding(SerializationInfo info, StreamingContext context)
        {
            // Any info?
            if (info==null) throw new ArgumentNullException("info");
            Contract.EndContractBlock();

            // All versions have a code page
            this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));

            // We can get dataItem on the fly if needed, and the index is different between versions
            // so ignore whatever dataItem data we get from Everett.
            this.dataItem   = null;

            // See if we have a code page
            try
            {
                //
                // Try Whidbey V2.0 Fields
                //

                this.m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool));

                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            }
            catch (SerializationException)
            {
                //
                // Didn't have Whidbey things, must be Everett
                //
                this.m_deserializedFromEverett = true;

                // May as well be read only
                this.m_isReadOnly = true;
                SetDefaultFallbacks();
            }
        }
示例#8
0
 private void OnSerializing(StreamingContext ctx)
 {
     // to be consistent with SerializeEncoding
     dataItem = null;
 }
示例#9
0
        internal void OnDeserialized()
        {
            if (encoderFallback == null || decoderFallback == null)
            {
                m_deserializedFromEverett = true;
                SetDefaultFallbacks();
            }

            // dataItem is always recalculated from the code page #
            dataItem = null;              
        }
示例#10
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        unsafe internal static CodePageDataItem GetCodePageDataItem(int codepage) { 
            CodePageDataItem dataItem;

            // We synchronize around dictionary gets/sets. There's still a possibility that two threads
            // will create a CodePageDataItem and the second will clobber the first in the dictionary. 
            // However, that's acceptable because the contents are correct and we make no guarantees
            // other than that. 
 
            //Look up the item in the hashtable.
            dataItem = (CodePageDataItem)hashByCodePage[codepage]; 

            //If we found it, return it.
            if (dataItem!=null) {
                return dataItem; 
            }
 
 
            //If we didn't find it, try looking it up now.
            //If we find it, add it to the hashtable. 
            //This is a linear search, but we probably won't be doing it very often.
            //
            int i = 0;
            int data; 
            while ((data = codePageDataPtr[i].codePage) != 0) {
                if (data == codepage) { 
                    dataItem = new CodePageDataItem(i); 
                    hashByCodePage[codepage] = dataItem;
                    return (dataItem); 
                }
                i++;
            }
 
            //Nope, we didn't find it.
            return null; 
        } 
     unsafe internal static CodePageDataItem GetCodePageDataItem(int codepage) {
         CodePageDataItem dataItem;
         
         //Look up the item in the hashtable.
         dataItem = (CodePageDataItem)hashByCodePage[codepage];
         
         //If we found it, return it.
         if (dataItem!=null) {
             return (dataItem);
         }
 
         //If we didn't find it, try looking it up now.
         //If we find it, add it to the hashtable.
         //This is a linear search, but we probably won't be doing it very often.
         //
         int i = 0;
         int data;
         while ((data = codePageDataPtr[i].codePage) != 0) {
             if (data==codepage) {
                 dataItem = new CodePageDataItem(i);
                 hashByCodePage[codepage]=dataItem;
                 return (dataItem);
             }
             i++;
         }
         //Nope, we didn't find it.
         return (null);
     }
示例#12
0
        // the following two methods are used for the inherited classes which implemented ISerializable
        // Deserialization Helper
        internal void DeserializeEncoding(SerializationInfo info, StreamingContext context)
        {
            // Any info?
            if (info==null) throw new ArgumentNullException("info");

            // All versions have a code page
            this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));

            this.dataItem   = null;

            // See if we have a code page
            try
            {

                this.m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool));

                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            }
            catch (SerializationException)
            {
                this.m_deserializedFromEverett = true;

                // May as well be read only
                this.m_isReadOnly = true;
                SetDefaultFallbacks();
            }
        }
 internal unsafe static EncodingInfo[] GetEncodings()
 {
     if (EncodingTable.lastCodePageItem == 0)
     {
         int num = 0;
         while (EncodingTable.codePageDataPtr[num].codePage != 0)
         {
             num++;
         }
         EncodingTable.lastCodePageItem = num;
     }
     EncodingInfo[] array = new EncodingInfo[EncodingTable.lastCodePageItem];
     for (int i = 0; i < EncodingTable.lastCodePageItem; i++)
     {
         array[i] = new EncodingInfo((int)EncodingTable.codePageDataPtr[i].codePage, CodePageDataItem.CreateString(EncodingTable.codePageDataPtr[i].Names, 0U), Environment.GetResourceString("Globalization.cp_" + EncodingTable.codePageDataPtr[i].codePage));
     }
     return(array);
 }
示例#14
0
 internal static unsafe EncodingInfo[] GetEncodings()
 {
     if (EncodingTable.lastCodePageItem == 0)
     {
         int index = 0;
         while ((int)EncodingTable.codePageDataPtr[index].codePage != 0)
         {
             ++index;
         }
         EncodingTable.lastCodePageItem = index;
     }
     EncodingInfo[] encodingInfoArray = new EncodingInfo[EncodingTable.lastCodePageItem];
     for (int index = 0; index < EncodingTable.lastCodePageItem; ++index)
     {
         encodingInfoArray[index] = new EncodingInfo((int)EncodingTable.codePageDataPtr[index].codePage, CodePageDataItem.CreateString(EncodingTable.codePageDataPtr[index].Names, 0U), Environment.GetResourceString("Globalization.cp_" + (object)EncodingTable.codePageDataPtr[index].codePage));
     }
     return(encodingInfoArray);
 }