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
- InstanceCreationEditor.cs
- EntityClientCacheKey.cs
- JulianCalendar.cs
- SessionState.cs
- ProjectionCamera.cs
- PageThemeParser.cs
- ProfilePropertyNameValidator.cs
- VoiceChangeEventArgs.cs
- TransformerTypeCollection.cs
- EntityTypeEmitter.cs
- DataGridRelationshipRow.cs
- CanonicalFontFamilyReference.cs
- Table.cs
- errorpatternmatcher.cs
- ClusterUtils.cs
- XmlSchemaAttributeGroupRef.cs
- AudioSignalProblemOccurredEventArgs.cs
- ValidationResult.cs
- XmlSchemaObjectTable.cs
- TemplateContainer.cs
- UrlMappingCollection.cs
- ConfigurationManagerInternal.cs
- BaseEntityWrapper.cs
- RegexMatchCollection.cs
- WmpBitmapDecoder.cs
- OSFeature.cs
- DataControlLinkButton.cs
- Quaternion.cs
- XmlExceptionHelper.cs
- MaterialCollection.cs
- TextTreeDeleteContentUndoUnit.cs
- CfgParser.cs
- SchemaImporter.cs
- ObjectNotFoundException.cs
- SymLanguageVendor.cs
- BoundPropertyEntry.cs
- ObjectMemberMapping.cs
- QueryOutputWriter.cs
- XmlReflectionMember.cs
- BlurBitmapEffect.cs
- RunInstallerAttribute.cs
- ConfigurationElement.cs
- Serializer.cs
- DecoderBestFitFallback.cs
- TypeInfo.cs
- EnumerableWrapperWeakToStrong.cs
- XPathDescendantIterator.cs
- UserControlDocumentDesigner.cs
- SerializationAttributes.cs
- ImageAnimator.cs
- SqlError.cs
- VisemeEventArgs.cs
- SynchronizedPool.cs
- SByte.cs
- ProtocolsConfigurationEntry.cs
- SerializableAttribute.cs
- TextServicesManager.cs
- DesignerPerfEventProvider.cs
- Transform3DGroup.cs
- SrgsItemList.cs
- WebPartCatalogAddVerb.cs
- LambdaCompiler.Address.cs
- PageTheme.cs
- SqlTriggerAttribute.cs
- XsltLoader.cs
- AssemblyBuilder.cs
- SessionStateUtil.cs
- FacetValues.cs
- SingleConverter.cs
- FontStyleConverter.cs
- ArraySubsetEnumerator.cs
- XmlMemberMapping.cs
- WebUtil.cs
- WebDescriptionAttribute.cs
- ScriptDescriptor.cs
- XmlValueConverter.cs
- IPAddressCollection.cs
- UInt32Storage.cs
- XmlSchema.cs
- CurrentChangedEventManager.cs
- RequestQueryParser.cs
- ToolboxComponentsCreatedEventArgs.cs
- PrimitiveSchema.cs
- WmiEventSink.cs
- ConnectionStringsSection.cs
- FormViewUpdateEventArgs.cs
- XamlBrushSerializer.cs
- TemplateBamlRecordReader.cs
- ContractComponent.cs
- TextModifier.cs
- EntityClassGenerator.cs
- RenderOptions.cs
- UInt32Converter.cs
- ValidationEventArgs.cs
- XmlSerializer.cs
- QueryOptionExpression.cs
- ExpressionNormalizer.cs
- NavigationWindow.cs
- ElementNotAvailableException.cs
- SystemIPv6InterfaceProperties.cs