Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ObjectDataSourceDisposingEventArgs.cs
- TreeWalkHelper.cs
- TypeDescriptor.cs
- StatusBarAutomationPeer.cs
- InvalidWMPVersionException.cs
- MemoryMappedFile.cs
- PreloadedPackages.cs
- Utility.cs
- IdentityElement.cs
- RenderData.cs
- XmlUTF8TextWriter.cs
- EllipseGeometry.cs
- TracedNativeMethods.cs
- WindowsStatusBar.cs
- SQLDouble.cs
- FontTypeConverter.cs
- SafeSecurityHelper.cs
- ExpanderAutomationPeer.cs
- FontCacheUtil.cs
- ConfigDefinitionUpdates.cs
- TypeConverters.cs
- ParentQuery.cs
- StoreItemCollection.Loader.cs
- LinkedList.cs
- Vector3DCollectionConverter.cs
- XPathAncestorQuery.cs
- TreeNodeCollectionEditor.cs
- FontFaceLayoutInfo.cs
- ExtensionDataObject.cs
- MatchingStyle.cs
- XamlDesignerSerializationManager.cs
- ListItemConverter.cs
- SchemaAttDef.cs
- FragmentQuery.cs
- ListMarkerLine.cs
- PermissionSetTriple.cs
- SQLInt16Storage.cs
- DiscoveryClientReferences.cs
- CustomAttributeFormatException.cs
- VerificationException.cs
- _IPv4Address.cs
- ZipPackagePart.cs
- AppDomainProtocolHandler.cs
- CodeNamespaceCollection.cs
- PolicyException.cs
- MailWebEventProvider.cs
- SqlUdtInfo.cs
- BaseProcessor.cs
- SequenceNumber.cs
- WebBrowser.cs
- ZipIOLocalFileBlock.cs
- ReturnValue.cs
- DbConnectionClosed.cs
- DBSqlParserTableCollection.cs
- xml.cs
- WCFModelStrings.Designer.cs
- MergablePropertyAttribute.cs
- Psha1DerivedKeyGenerator.cs
- Block.cs
- EventLogger.cs
- SafeReversePInvokeHandle.cs
- OptimisticConcurrencyException.cs
- CompiledRegexRunnerFactory.cs
- StatusBarItemAutomationPeer.cs
- XmlIgnoreAttribute.cs
- UnicastIPAddressInformationCollection.cs
- ellipse.cs
- NullableLongMinMaxAggregationOperator.cs
- PersonalizationState.cs
- TypeConverterHelper.cs
- DataGridViewIntLinkedList.cs
- GroupByQueryOperator.cs
- FixedSOMContainer.cs
- Itemizer.cs
- TextClipboardData.cs
- NativeMethods.cs
- SignatureTargetIdManager.cs
- EntityParameterCollection.cs
- TypeConverterAttribute.cs
- ProtocolElement.cs
- SchemaObjectWriter.cs
- ClientBuildManagerCallback.cs
- ZoneLinkButton.cs
- UnmanagedMemoryStream.cs
- SectionVisual.cs
- Tag.cs
- MessageSmuggler.cs
- Pointer.cs
- SynchronizationHandlesCodeDomSerializer.cs
- GestureRecognitionResult.cs
- OuterGlowBitmapEffect.cs
- NestedContainer.cs
- XamlFigureLengthSerializer.cs
- _AutoWebProxyScriptEngine.cs
- DataRelationPropertyDescriptor.cs
- OleDbCommand.cs
- ReachPrintTicketSerializer.cs
- WebPartConnectionsCancelEventArgs.cs
- ToolStripInSituService.cs
- DataKey.cs