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
- RuntimeConfigurationRecord.cs
- QilVisitor.cs
- AsyncOperation.cs
- ServiceParser.cs
- SamlSecurityToken.cs
- StrongNamePublicKeyBlob.cs
- ListControlDataBindingHandler.cs
- GridLengthConverter.cs
- TypeUsageBuilder.cs
- ObjectConverter.cs
- AspNetSynchronizationContext.cs
- HtmlControlDesigner.cs
- ErrorStyle.cs
- EmptyQuery.cs
- UDPClient.cs
- SynchronizedDispatch.cs
- RichTextBoxAutomationPeer.cs
- CompModSwitches.cs
- ActivitySurrogateSelector.cs
- MappingSource.cs
- ItemCollection.cs
- NumericUpDownAcceleration.cs
- SuppressedPackageProperties.cs
- SqlParameter.cs
- RemotingConfigParser.cs
- ActivationServices.cs
- RSAOAEPKeyExchangeFormatter.cs
- ConfigXmlElement.cs
- ProviderBase.cs
- BrowserCapabilitiesFactory.cs
- ExpandedWrapper.cs
- AuthenticationConfig.cs
- Scheduling.cs
- DbConnectionInternal.cs
- PageCache.cs
- TerminatorSinks.cs
- SrgsRuleRef.cs
- LineBreakRecord.cs
- SystemWebCachingSectionGroup.cs
- ValueUtilsSmi.cs
- metadatamappinghashervisitor.cs
- AttributeSetAction.cs
- DirtyTextRange.cs
- DiscoveryExceptionDictionary.cs
- ExtendedPropertyDescriptor.cs
- DynamicPropertyHolder.cs
- XPathItem.cs
- InkCanvasSelection.cs
- InvokeSchedule.cs
- DataFieldConverter.cs
- ISSmlParser.cs
- MailHeaderInfo.cs
- HtmlElement.cs
- DocumentGridPage.cs
- Profiler.cs
- EntityConnection.cs
- UrlPath.cs
- FormsAuthenticationEventArgs.cs
- PageAsyncTask.cs
- DataGridViewRowsAddedEventArgs.cs
- HtmlTable.cs
- OutOfProcStateClientManager.cs
- HtmlFormParameterReader.cs
- ZipArchive.cs
- DynamicDataRoute.cs
- ConnectionConsumerAttribute.cs
- EmptyControlCollection.cs
- QilFunction.cs
- BuildProvider.cs
- SqlClientFactory.cs
- ManagementClass.cs
- DbProviderServices.cs
- ChtmlTextBoxAdapter.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- DesignerSerializerAttribute.cs
- BCLDebug.cs
- ErrorWebPart.cs
- RestClientProxyHandler.cs
- DataServiceContext.cs
- JsonQNameDataContract.cs
- DataGridViewControlCollection.cs
- ProcessModelSection.cs
- DrawingContextWalker.cs
- CharacterString.cs
- ParameterModifier.cs
- TextTreeTextElementNode.cs
- DependencyPropertyValueSerializer.cs
- TextDecorationCollectionConverter.cs
- VersionedStreamOwner.cs
- UnlockInstanceAsyncResult.cs
- HtmlContainerControl.cs
- TakeQueryOptionExpression.cs
- HttpGetProtocolImporter.cs
- OletxTransactionFormatter.cs
- XmlCountingReader.cs
- InputLangChangeRequestEvent.cs
- CssClassPropertyAttribute.cs
- ChannelHandler.cs
- ColumnClickEvent.cs
- FusionWrap.cs