Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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
- EmptyStringExpandableObjectConverter.cs
- DataRow.cs
- CompiledRegexRunner.cs
- SubclassTypeValidator.cs
- __Filters.cs
- MeasureItemEvent.cs
- RelationshipSet.cs
- ActionNotSupportedException.cs
- SecurityRuntime.cs
- ResourcesChangeInfo.cs
- Timer.cs
- CodeDirectionExpression.cs
- ExtenderProvidedPropertyAttribute.cs
- IndependentAnimationStorage.cs
- CommonProperties.cs
- prefixendpointaddressmessagefiltertable.cs
- EmptyQuery.cs
- ReflectionServiceProvider.cs
- CompilationSection.cs
- LicenseException.cs
- IgnoreSection.cs
- Propagator.JoinPropagator.cs
- PixelFormats.cs
- AmbientLight.cs
- FlowDocumentView.cs
- SchemaDeclBase.cs
- DbConnectionInternal.cs
- StateWorkerRequest.cs
- CreateUserErrorEventArgs.cs
- listitem.cs
- DnsPermission.cs
- XmlCDATASection.cs
- ISAPIWorkerRequest.cs
- DemultiplexingClientMessageFormatter.cs
- DrawingBrush.cs
- DefaultMemberAttribute.cs
- coordinatorfactory.cs
- SQLMembershipProvider.cs
- RsaKeyIdentifierClause.cs
- IndentedTextWriter.cs
- RemotingServices.cs
- mactripleDES.cs
- ScriptManagerProxy.cs
- StructuredTypeEmitter.cs
- ParserStack.cs
- DefaultHttpHandler.cs
- TdsParser.cs
- WebPartConnectionsCancelVerb.cs
- Socket.cs
- XmlDataSourceView.cs
- DecimalKeyFrameCollection.cs
- UnmanagedMarshal.cs
- HybridDictionary.cs
- LicFileLicenseProvider.cs
- Rijndael.cs
- IntSecurity.cs
- sqlmetadatafactory.cs
- DragSelectionMessageFilter.cs
- DependencyPropertyAttribute.cs
- DbBuffer.cs
- ArglessEventHandlerProxy.cs
- RemotingException.cs
- XmlSerializerSection.cs
- Function.cs
- HostProtectionException.cs
- TemplatedWizardStep.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DateTimeConverter.cs
- RowToParametersTransformer.cs
- EventEntry.cs
- TemplatePagerField.cs
- ShaderEffect.cs
- IntranetCredentialPolicy.cs
- ListControl.cs
- HttpHandler.cs
- IgnorePropertiesAttribute.cs
- UTF8Encoding.cs
- Vector3DCollectionConverter.cs
- BuilderInfo.cs
- DropAnimation.xaml.cs
- SamlSecurityTokenAuthenticator.cs
- AuthenticationSection.cs
- StylusSystemGestureEventArgs.cs
- Int32AnimationBase.cs
- Empty.cs
- XmlChildNodes.cs
- DataSourceSerializationException.cs
- FactoryGenerator.cs
- MemoryStream.cs
- ContextMenuAutomationPeer.cs
- PerspectiveCamera.cs
- EntityContainerAssociationSet.cs
- XmlAnyElementAttributes.cs
- AssociationTypeEmitter.cs
- EnumerableCollectionView.cs
- CompilerParameters.cs
- NameValuePermission.cs
- EventPrivateKey.cs
- shaperfactory.cs
- BasicViewGenerator.cs