Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Text / EncoderExceptionFallback.cs / 1 / EncoderExceptionFallback.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // EncoderExceptionFallback.cs namespace System.Text { using System; using System.Runtime.Serialization; [Serializable] public sealed class EncoderExceptionFallback : EncoderFallback { // Construction public EncoderExceptionFallback() { } public override EncoderFallbackBuffer CreateFallbackBuffer() { return new EncoderExceptionFallbackBuffer(); } // Maximum number of characters that this instance of this fallback could return public override int MaxCharCount { get { return 0; } } public override bool Equals(Object value) { EncoderExceptionFallback that = value as EncoderExceptionFallback; if (that != null) { return (true); } return (false); } public override int GetHashCode() { return 654; } } public sealed class EncoderExceptionFallbackBuffer : EncoderFallbackBuffer { public override bool Fallback(char charUnknown, int index) { // Fall back our char throw new EncoderFallbackException( Environment.GetResourceString("Argument_InvalidCodePageConversionIndex", (int)charUnknown, index), charUnknown, index); } public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) { if (!Char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException("charUnknownHigh", Environment.GetResourceString("ArgumentOutOfRange_Range", 0xD800, 0xDBFF)); } if (!Char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException("CharUnknownLow", Environment.GetResourceString("ArgumentOutOfRange_Range", 0xDC00, 0xDFFF)); } int iTemp = Char.ConvertToUtf32(charUnknownHigh, charUnknownLow); // Fall back our char throw new EncoderFallbackException( Environment.GetResourceString("Argument_InvalidCodePageConversionIndex", iTemp, index), charUnknownHigh, charUnknownLow, index); } public override char GetNextChar() { return (char)0; } public override bool MovePrevious() { // Exception fallback doesn't have anywhere to back up to. return false; } // Exceptions are always empty public override int Remaining { get { return 0; } } } [Serializable] public sealed class EncoderFallbackException : ArgumentException { char charUnknown; char charUnknownHigh; char charUnknownLow; int index; public EncoderFallbackException() : base(Environment.GetResourceString("Arg_ArgumentException")) { SetErrorCode(__HResults.COR_E_ARGUMENT); } public EncoderFallbackException(String message) : base(message) { SetErrorCode(__HResults.COR_E_ARGUMENT); } public EncoderFallbackException(String message, Exception innerException) : base(message, innerException) { SetErrorCode(__HResults.COR_E_ARGUMENT); } internal EncoderFallbackException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal EncoderFallbackException( String message, char charUnknown, int index) : base(message) { this.charUnknown = charUnknown; this.index = index; } internal EncoderFallbackException( String message, char charUnknownHigh, char charUnknownLow, int index) : base(message) { if (!Char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException("charUnknownHigh", Environment.GetResourceString("ArgumentOutOfRange_Range", 0xD800, 0xDBFF)); } if (!Char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException("CharUnknownLow", Environment.GetResourceString("ArgumentOutOfRange_Range", 0xDC00, 0xDFFF)); } this.charUnknownHigh = charUnknownHigh; this.charUnknownLow = charUnknownLow; this.index = index; } public char CharUnknown { get { return (charUnknown); } } public char CharUnknownHigh { get { return (charUnknownHigh); } } public char CharUnknownLow { get { return (charUnknownLow); } } public int Index { get { return index; } } // Return true if the unknown character is a surrogate pair. public bool IsUnknownSurrogate() { return (this.charUnknownHigh != '\0'); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FixedSOMTableRow.cs
- SchemaTableColumn.cs
- BmpBitmapDecoder.cs
- CryptoProvider.cs
- WebConfigurationManager.cs
- ContentOperations.cs
- TypeLibConverter.cs
- SocketElement.cs
- ForEachAction.cs
- ToolTipService.cs
- DateTimeOffsetStorage.cs
- MessageSmuggler.cs
- ToolTipService.cs
- BitmapPalettes.cs
- DataGridViewComboBoxCell.cs
- FontStretchConverter.cs
- DeclaredTypeValidator.cs
- ObjectViewListener.cs
- _ListenerResponseStream.cs
- ToolStripItemClickedEventArgs.cs
- xmlsaver.cs
- PropertyConverter.cs
- FontClient.cs
- RemoteHelper.cs
- LinqExpressionNormalizer.cs
- TdsParser.cs
- ObjectQuery.cs
- MSG.cs
- Source.cs
- DictionaryItemsCollection.cs
- ContainerSelectorBehavior.cs
- ListenUriMode.cs
- CommandDevice.cs
- OutputCacheProviderCollection.cs
- MeshGeometry3D.cs
- PropertyFilterAttribute.cs
- FragmentQuery.cs
- DataGridViewUtilities.cs
- CollectionView.cs
- UInt64.cs
- EndpointDispatcherTable.cs
- Enlistment.cs
- ElementFactory.cs
- SimpleType.cs
- UpdateCommand.cs
- mactripleDES.cs
- SplitContainer.cs
- SqlProfileProvider.cs
- ListCollectionView.cs
- SmtpNegotiateAuthenticationModule.cs
- __ConsoleStream.cs
- CommonProperties.cs
- SqlConnectionPoolGroupProviderInfo.cs
- AbsoluteQuery.cs
- TextEditorTyping.cs
- ColorKeyFrameCollection.cs
- SerializationAttributes.cs
- ApplicationInfo.cs
- Cursor.cs
- ModelTreeManager.cs
- DataGridViewButtonColumn.cs
- SplashScreen.cs
- IfJoinedCondition.cs
- ColorConverter.cs
- IdentityManager.cs
- HostProtectionException.cs
- TextTreeInsertElementUndoUnit.cs
- DataSourceControl.cs
- QualifiedCellIdBoolean.cs
- ColorTransform.cs
- TextTreeTextElementNode.cs
- RecommendedAsConfigurableAttribute.cs
- VideoDrawing.cs
- MailHeaderInfo.cs
- MobileErrorInfo.cs
- RegionInfo.cs
- SelectionEditingBehavior.cs
- ControlBuilderAttribute.cs
- LookupBindingPropertiesAttribute.cs
- EventDescriptorCollection.cs
- SharedConnectionWorkflowTransactionService.cs
- SQLConvert.cs
- CompareValidator.cs
- ConsumerConnectionPointCollection.cs
- Msec.cs
- BrowserCapabilitiesCodeGenerator.cs
- BrowserCapabilitiesFactory.cs
- MSAAWinEventWrap.cs
- ListChangedEventArgs.cs
- TableRowCollection.cs
- dbenumerator.cs
- CodeDomSerializerBase.cs
- MappingException.cs
- ErrorHandler.cs
- cookiecollection.cs
- PropertyGrid.cs
- DataKey.cs
- RelationshipDetailsCollection.cs
- FontInfo.cs
- TransactionWaitAsyncResult.cs