Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Core / IncrementalReadDecoders.cs / 1305376 / 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(); } #if !SILVERLIGHT // Needed only for XmlTextReader // // 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; } } #endif } // 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(); } #if !SILVERLIGHT // Needed only for XmlTextReader // // 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; } } #endif } // 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
- DescendantBaseQuery.cs
- ToolStripDesignerAvailabilityAttribute.cs
- PaperSource.cs
- Binding.cs
- PageCatalogPart.cs
- DecoderFallback.cs
- GridViewDeletedEventArgs.cs
- SynchronizedDispatch.cs
- TypeRestriction.cs
- DataGridViewCheckBoxColumn.cs
- ColumnReorderedEventArgs.cs
- SynchronousChannelMergeEnumerator.cs
- CompiledAction.cs
- LicenseContext.cs
- ManagedCodeMarkers.cs
- OleDbSchemaGuid.cs
- DBSchemaTable.cs
- _UriSyntax.cs
- TypeSystemProvider.cs
- InputLanguage.cs
- HandleTable.cs
- RoleManagerSection.cs
- DispatcherExceptionEventArgs.cs
- DelegateArgumentValue.cs
- XmlRawWriterWrapper.cs
- XmlUtil.cs
- DataGridColumn.cs
- ArrayTypeMismatchException.cs
- GridViewColumnCollectionChangedEventArgs.cs
- WindowsGraphicsCacheManager.cs
- AccessViolationException.cs
- EventBuilder.cs
- ChangePassword.cs
- SchemaNamespaceManager.cs
- RoleExceptions.cs
- WindowsListViewScroll.cs
- BatchWriter.cs
- TrackingCondition.cs
- TabItemWrapperAutomationPeer.cs
- StringValidatorAttribute.cs
- nulltextnavigator.cs
- ClientSideQueueItem.cs
- DynamicValidatorEventArgs.cs
- UnitySerializationHolder.cs
- MetadataUtilsSmi.cs
- URIFormatException.cs
- TextEditorThreadLocalStore.cs
- HScrollBar.cs
- ContextMarshalException.cs
- TraceContextEventArgs.cs
- CopyOnWriteList.cs
- ButtonField.cs
- StylusButton.cs
- DesignerCatalogPartChrome.cs
- WorkflowTransactionOptions.cs
- AdPostCacheSubstitution.cs
- PolyBezierSegmentFigureLogic.cs
- InlineCollection.cs
- Point3DValueSerializer.cs
- UniformGrid.cs
- SelectionRange.cs
- MetadataCache.cs
- Stackframe.cs
- Section.cs
- TemplateKeyConverter.cs
- OdbcErrorCollection.cs
- MenuAdapter.cs
- WebPart.cs
- UIElementHelper.cs
- OleDbInfoMessageEvent.cs
- SemanticValue.cs
- RawTextInputReport.cs
- AddInProcess.cs
- InvalidFilterCriteriaException.cs
- Activator.cs
- TabItem.cs
- X509RawDataKeyIdentifierClause.cs
- XmlDigitalSignatureProcessor.cs
- MessageDecoder.cs
- TableLayoutStyle.cs
- CodeMemberMethod.cs
- ProxyWebPart.cs
- SerialPinChanges.cs
- LinqDataSourceView.cs
- BadImageFormatException.cs
- LongSumAggregationOperator.cs
- ThicknessAnimationBase.cs
- DocumentReferenceCollection.cs
- DBDataPermission.cs
- ICollection.cs
- GlyphShapingProperties.cs
- IisTraceWebEventProvider.cs
- CodeAttributeDeclaration.cs
- FileEnumerator.cs
- OrderByBuilder.cs
- ProxySimple.cs
- ConfigsHelper.cs
- Ppl.cs
- LabelLiteral.cs
- LayoutTable.cs