Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / Core / IncrementalReadDecoders.cs / 1 / IncrementalReadDecoders.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Diagnostics; namespace System.Xml { // // IncrementalReadDecoder abstract class // internal abstract class IncrementalReadDecoder { internal abstract int DecodedCount { get; } internal abstract bool IsFull { get; } internal abstract void SetNextOutputBuffer( Array array, int offset, int len ); internal abstract int Decode( char[] chars, int startPos, int len ); internal abstract int Decode( string str, int startPos, int len ); internal abstract void Reset(); } // // Dummy IncrementalReadDecoder // internal class IncrementalReadDummyDecoder : IncrementalReadDecoder { internal override int DecodedCount { get { return -1; } } internal override bool IsFull { get { return false; } } internal override void SetNextOutputBuffer( Array array, int offset, int len ) {} internal override int Decode( char[] chars, int startPos, int len ) { return len; } internal override int Decode( string str, int startPos, int len ) { return len; } internal override void Reset() {} } // // IncrementalReadDecoder for ReadChars // internal class IncrementalReadCharsDecoder : IncrementalReadDecoder { char[] buffer; int startIndex; int curIndex; int endIndex; internal IncrementalReadCharsDecoder() { } internal override int DecodedCount { get { return curIndex - startIndex; } } internal override bool IsFull { get { return curIndex == endIndex; } } internal override int Decode( char[] chars, int startPos, int len ) { Debug.Assert( chars != null ); Debug.Assert( len >= 0 ); Debug.Assert( startPos >= 0 ); Debug.Assert( chars.Length - startPos >= len ); Debug.Assert( len > 0 ); int copyCount = endIndex - curIndex; if ( copyCount > len ) { copyCount = len; } Buffer.BlockCopy( chars, startPos * 2, buffer, curIndex * 2, copyCount * 2 ); curIndex += copyCount; return copyCount; } internal override int Decode( string str, int startPos, int len ) { Debug.Assert( str != null ); Debug.Assert( len >= 0 ); Debug.Assert( startPos >= 0 ); Debug.Assert( str.Length - startPos >= len ); Debug.Assert( len > 0 ); int copyCount = endIndex - curIndex; if ( copyCount > len ) { copyCount = len; } str.CopyTo( startPos, buffer, curIndex, copyCount ); curIndex += copyCount; return copyCount; } internal override void Reset() { } internal override void SetNextOutputBuffer( Array buffer, int index, int count ) { Debug.Assert( buffer != null ); Debug.Assert( count >= 0 ); Debug.Assert( index >= 0 ); Debug.Assert( buffer.Length - index >= count ); Debug.Assert( ( buffer as char[] ) != null ); this.buffer = (char[])buffer; this.startIndex = index; this.curIndex = index; this.endIndex = index + count; } } } // 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
- ResourceBinder.cs
- TextRenderingModeValidation.cs
- EnumValidator.cs
- OpenTypeLayout.cs
- DivideByZeroException.cs
- ELinqQueryState.cs
- Animatable.cs
- DependencyPropertyChangedEventArgs.cs
- XPathPatternBuilder.cs
- Matrix3DStack.cs
- SByteStorage.cs
- InfoCardSymmetricAlgorithm.cs
- XmlIlGenerator.cs
- HtmlInputButton.cs
- BitmapEffectOutputConnector.cs
- QilTypeChecker.cs
- SupportsPreviewControlAttribute.cs
- SafeFileMappingHandle.cs
- PageCatalogPart.cs
- GenericEnumConverter.cs
- TypeConverter.cs
- WizardForm.cs
- PanningMessageFilter.cs
- UriTemplateQueryValue.cs
- Internal.cs
- MatrixStack.cs
- DataTableExtensions.cs
- WebPartPersonalization.cs
- TextProperties.cs
- MimeParameters.cs
- ObjectDataSourceMethodEventArgs.cs
- Utils.cs
- WebPartTransformer.cs
- MultiSelectRootGridEntry.cs
- IPPacketInformation.cs
- XmlSecureResolver.cs
- InlineCollection.cs
- Border.cs
- LicenseProviderAttribute.cs
- WindowsRegion.cs
- ApplicationSecurityManager.cs
- NativeRecognizer.cs
- FacetValueContainer.cs
- EasingKeyFrames.cs
- IgnorePropertiesAttribute.cs
- StaticDataManager.cs
- NameSpaceExtractor.cs
- BitmapEffectGroup.cs
- ProfileBuildProvider.cs
- MediaPlayerState.cs
- ModelMemberCollection.cs
- FlowNode.cs
- RuntimeConfigLKG.cs
- FrameSecurityDescriptor.cs
- BaseParagraph.cs
- EndpointDiscoveryElement.cs
- Semaphore.cs
- HelloMessage11.cs
- XXXInfos.cs
- SeverityFilter.cs
- HostProtectionException.cs
- WebServicesSection.cs
- PropertyRef.cs
- X509RecipientCertificateServiceElement.cs
- ToolStripPanel.cs
- TypeListConverter.cs
- InputLanguage.cs
- Point3DValueSerializer.cs
- DbConnectionPoolIdentity.cs
- OptimizedTemplateContentHelper.cs
- ElementHostAutomationPeer.cs
- DataSetFieldSchema.cs
- HGlobalSafeHandle.cs
- ChildTable.cs
- ProfileProvider.cs
- SiteMapPathDesigner.cs
- PageThemeBuildProvider.cs
- ErrorLog.cs
- UIElement.cs
- NodeFunctions.cs
- LingerOption.cs
- XmlReflectionImporter.cs
- XPathDocumentIterator.cs
- LinearGradientBrush.cs
- AesCryptoServiceProvider.cs
- GifBitmapDecoder.cs
- ComPersistableTypeElementCollection.cs
- DataGridHeaderBorder.cs
- TreeWalker.cs
- ReceiveMessageRecord.cs
- HttpsChannelListener.cs
- DataViewSetting.cs
- VisualStyleElement.cs
- TextSchema.cs
- StorageRoot.cs
- FontDifferentiator.cs
- PenThreadPool.cs
- ReflectEventDescriptor.cs
- ImportOptions.cs
- ControlIdConverter.cs