Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //[....] //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TabletCollection.cs
- BrushConverter.cs
- ProxyDataContractResolver.cs
- WebBrowserBase.cs
- MissingFieldException.cs
- AuthenticationModeHelper.cs
- Dictionary.cs
- userdatakeys.cs
- sqlpipe.cs
- FlagsAttribute.cs
- SqlUtils.cs
- EventlogProvider.cs
- HttpApplicationStateBase.cs
- SynchronizedInputAdaptor.cs
- CodeGroup.cs
- WebDescriptionAttribute.cs
- DocumentPaginator.cs
- RectAnimationClockResource.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- ReferenceAssemblyAttribute.cs
- CodeSubDirectory.cs
- XmlNode.cs
- EventProviderBase.cs
- ServiceModelDictionary.cs
- FormattedTextSymbols.cs
- XsltFunctions.cs
- LifetimeServices.cs
- SegmentInfo.cs
- EventKeyword.cs
- MouseActionValueSerializer.cs
- ArrowControl.xaml.cs
- XmlSchemaValidationException.cs
- ZoneMembershipCondition.cs
- RsaSecurityKey.cs
- RadioButtonBaseAdapter.cs
- Input.cs
- HttpChannelHelpers.cs
- DateTimePickerDesigner.cs
- StyleTypedPropertyAttribute.cs
- BitmapData.cs
- CompositeActivityMarkupSerializer.cs
- AccessDataSource.cs
- XmlUtil.cs
- MessageDirection.cs
- QilInvokeEarlyBound.cs
- FieldToken.cs
- DataTemplate.cs
- Rijndael.cs
- SecurityException.cs
- DbConnectionHelper.cs
- InkSerializer.cs
- DispatcherHooks.cs
- AssociationType.cs
- __FastResourceComparer.cs
- PerfService.cs
- RepeaterItemCollection.cs
- SecurityManager.cs
- RemotingHelper.cs
- PropertyTabAttribute.cs
- RefreshEventArgs.cs
- OdbcConnectionPoolProviderInfo.cs
- RecognizedAudio.cs
- ConfigXmlText.cs
- AppSettingsExpressionBuilder.cs
- WebPartDescriptionCollection.cs
- PersonalizationProviderHelper.cs
- ObjectPersistData.cs
- EntityDataSourceUtil.cs
- XmlJsonWriter.cs
- EncodedStreamFactory.cs
- AuthorizationRuleCollection.cs
- ExtractCollection.cs
- PageHandlerFactory.cs
- wgx_sdk_version.cs
- Page.cs
- OracleString.cs
- FileNotFoundException.cs
- RegistryConfigurationProvider.cs
- Tracer.cs
- EmptyEnumerator.cs
- DocComment.cs
- FastEncoder.cs
- VisualTreeUtils.cs
- UserControlParser.cs
- DataGrid.cs
- SequenceDesigner.cs
- FullTextBreakpoint.cs
- StartUpEventArgs.cs
- WebPartUserCapability.cs
- CopyOnWriteList.cs
- SmiEventSink_Default.cs
- METAHEADER.cs
- RawMouseInputReport.cs
- DataGridViewCellStyle.cs
- RegularExpressionValidator.cs
- FixedPosition.cs
- MouseGesture.cs
- CellTreeNodeVisitors.cs
- Viewport2DVisual3D.cs
- DigitShape.cs