Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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');
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObjectDataSourceDesigner.cs
- ResumeStoryboard.cs
- WebPartEditorApplyVerb.cs
- SimpleNameService.cs
- BindingOperations.cs
- RuleValidation.cs
- xmlsaver.cs
- LambdaCompiler.Generated.cs
- PlatformCulture.cs
- XmlILOptimizerVisitor.cs
- HiddenField.cs
- ConstructorExpr.cs
- RemotingAttributes.cs
- SerTrace.cs
- Event.cs
- StateBag.cs
- uribuilder.cs
- SectionRecord.cs
- EnumDataContract.cs
- HttpRequest.cs
- AnnotationResourceCollection.cs
- LogReservationCollection.cs
- DataControlFieldHeaderCell.cs
- HttpSocketManager.cs
- TrackingProfileDeserializationException.cs
- MenuItemBindingCollection.cs
- DataGridTextBoxColumn.cs
- ZipFileInfo.cs
- SiteMapNodeCollection.cs
- HtmlHead.cs
- FunctionDescription.cs
- SemanticBasicElement.cs
- Metadata.cs
- ExtractedStateEntry.cs
- FilePrompt.cs
- safemediahandle.cs
- SmtpNegotiateAuthenticationModule.cs
- SplitterEvent.cs
- ToolStripLocationCancelEventArgs.cs
- FocusWithinProperty.cs
- NullableDecimalAverageAggregationOperator.cs
- SoapEnumAttribute.cs
- Int32Rect.cs
- TokenCreationParameter.cs
- login.cs
- BitmapEffect.cs
- TextOptionsInternal.cs
- WebEvents.cs
- CollectionsUtil.cs
- NetworkInformationPermission.cs
- ChangeBlockUndoRecord.cs
- Visitors.cs
- HtmlHead.cs
- ProviderUtil.cs
- CurrentChangedEventManager.cs
- SpellerInterop.cs
- StateDesigner.LayoutSelectionGlyph.cs
- SimpleBitVector32.cs
- GeneralTransform3DCollection.cs
- Soap12ServerProtocol.cs
- LOSFormatter.cs
- TargetConverter.cs
- StretchValidation.cs
- ParameterToken.cs
- SizeFConverter.cs
- TcpServerChannel.cs
- GrammarBuilderWildcard.cs
- SettingsBase.cs
- BrowserTree.cs
- WebPageTraceListener.cs
- WSSecurityTokenSerializer.cs
- WebServicesSection.cs
- XmlSerializerSection.cs
- FamilyMap.cs
- BitmapDecoder.cs
- Figure.cs
- ListViewInsertedEventArgs.cs
- GlobalizationSection.cs
- XamlStyleSerializer.cs
- SoapConverter.cs
- CellTreeSimplifier.cs
- HttpException.cs
- ConfigXmlDocument.cs
- PassportIdentity.cs
- LinqDataSourceUpdateEventArgs.cs
- GroupDescription.cs
- SortedList.cs
- HitTestParameters.cs
- IPAddress.cs
- RenderingBiasValidation.cs
- LinearGradientBrush.cs
- coordinatorfactory.cs
- GraphicsContext.cs
- ConfigurationManagerInternalFactory.cs
- WindowHelperService.cs
- OutOfProcStateClientManager.cs
- EnumMember.cs
- SqlTransaction.cs
- TabPage.cs
- RepeaterCommandEventArgs.cs