Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Text / EncoderExceptionFallback.cs / 1305376 / EncoderExceptionFallback.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // EncoderExceptionFallback.cs namespace System.Text { using System; using System.Runtime.Serialization; using System.Diagnostics.Contracts; [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 EncoderExceptionFallbackBuffer(){} 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)); } Contract.EndContractBlock(); 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)); } Contract.EndContractBlock(); 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'); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MouseGestureValueSerializer.cs
- DBAsyncResult.cs
- ColorMap.cs
- TextEffectResolver.cs
- SessionSwitchEventArgs.cs
- TypeInformation.cs
- UntrustedRecipientException.cs
- CombinedGeometry.cs
- FilterableData.cs
- Component.cs
- TextParentUndoUnit.cs
- GridViewCommandEventArgs.cs
- BookmarkResumptionRecord.cs
- DWriteFactory.cs
- DateTimeConstantAttribute.cs
- PointLight.cs
- TabItemWrapperAutomationPeer.cs
- MouseOverProperty.cs
- Journal.cs
- AncestorChangedEventArgs.cs
- Scene3D.cs
- ParseChildrenAsPropertiesAttribute.cs
- ConfigXmlText.cs
- WindowsGraphics2.cs
- ClrPerspective.cs
- CollectionChangeEventArgs.cs
- Activation.cs
- ValidationHelper.cs
- SQLBoolean.cs
- InfoCardRequestException.cs
- CompareValidator.cs
- SimpleRecyclingCache.cs
- CancelEventArgs.cs
- FrameworkElement.cs
- WindowsNonControl.cs
- SvcMapFileLoader.cs
- FormViewPageEventArgs.cs
- ToolStripScrollButton.cs
- PageHandlerFactory.cs
- TemplateField.cs
- Wow64ConfigurationLoader.cs
- DiscoveryService.cs
- ProxyManager.cs
- XmlQueryTypeFactory.cs
- EnlistmentTraceIdentifier.cs
- EntityViewGenerator.cs
- ExtenderControl.cs
- MemberPath.cs
- HMACRIPEMD160.cs
- RankException.cs
- MinimizableAttributeTypeConverter.cs
- KoreanLunisolarCalendar.cs
- SettingsProviderCollection.cs
- OrderedHashRepartitionEnumerator.cs
- CompositeControl.cs
- AsymmetricSignatureDeformatter.cs
- ElementProxy.cs
- SmtpAuthenticationManager.cs
- WebEventCodes.cs
- TTSEngineProxy.cs
- HttpHandler.cs
- FormParameter.cs
- ObjectStateEntryDbDataRecord.cs
- TrackingProfileManager.cs
- ToolStripComboBox.cs
- ExpanderAutomationPeer.cs
- DataTemplateSelector.cs
- SingleAnimationBase.cs
- ResourceDescriptionAttribute.cs
- SerializationIncompleteException.cs
- ListViewUpdateEventArgs.cs
- SafeCoTaskMem.cs
- DependencyPropertyHelper.cs
- StructuredTypeEmitter.cs
- Panel.cs
- BuildResult.cs
- IndentedWriter.cs
- ProfileGroupSettings.cs
- ClientBuildManager.cs
- RenderData.cs
- SoundPlayer.cs
- IndicFontClient.cs
- BevelBitmapEffect.cs
- HtmlTitle.cs
- XmlUtf8RawTextWriter.cs
- SeverityFilter.cs
- TemplateControlCodeDomTreeGenerator.cs
- DivideByZeroException.cs
- ArrayTypeMismatchException.cs
- ZipFileInfoCollection.cs
- DiagnosticTraceSource.cs
- FixedSOMTableCell.cs
- ClientTargetCollection.cs
- CssClassPropertyAttribute.cs
- FormsAuthenticationConfiguration.cs
- ParserStack.cs
- SyntaxCheck.cs
- ProcessProtocolHandler.cs
- UniformGrid.cs
- ScriptIgnoreAttribute.cs