Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / Xml / System / Xml / BinHexEncoder.cs / 1 / BinHexEncoder.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml {
internal abstract class BinHexEncoder {
private const string s_hexDigits = "0123456789ABCDEF";
private const int CharsChunkSize = 128;
internal static void Encode( byte[] buffer, int index, int count, XmlWriter writer ) {
if ( buffer == null ) {
throw new ArgumentNullException( "buffer" );
}
if ( index < 0 ) {
throw new ArgumentOutOfRangeException( "index" );
}
if ( count < 0 ) {
throw new ArgumentOutOfRangeException( "count" );
}
if ( count > buffer.Length - index ) {
throw new ArgumentOutOfRangeException( "count" );
}
char[] chars = new char[ ( count * 2 ) < CharsChunkSize ? ( count * 2 ) : CharsChunkSize ];
int endIndex = index + count;
while ( index < endIndex ) {
int cnt = ( count < CharsChunkSize/2 ) ? count : CharsChunkSize/2;
int charCount = Encode( buffer, index, cnt, chars );
writer.WriteRaw( chars, 0, charCount );
index += cnt;
count -= cnt;
}
}
internal static string Encode(byte[] inArray, int offsetIn, int count) {
if (null == inArray) {
throw new ArgumentNullException("inArray");
}
if (0 > offsetIn) {
throw new ArgumentOutOfRangeException("offsetIn");
}
if (0 > count) {
throw new ArgumentOutOfRangeException("count");
}
if (count > inArray.Length - offsetIn) {
throw new ArgumentOutOfRangeException("count");
}
char[] outArray = new char[2 * count];
int lenOut = Encode(inArray, offsetIn, count, outArray);
return new String(outArray, 0, lenOut);
}
private static int Encode(byte[] inArray, int offsetIn, int count, char[] outArray) {
int curOffsetOut =0, offsetOut = 0;
byte b;
int lengthOut = outArray.Length;
for (int j=0; j> 4];
if (curOffsetOut == lengthOut) {
break;
}
outArray[curOffsetOut ++] = s_hexDigits[b & 0xF];
if (curOffsetOut == lengthOut) {
break;
}
}
return curOffsetOut - offsetOut;
} // function
} // class
} // namespace
// 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
- MimePart.cs
- LambdaCompiler.Address.cs
- PolyBezierSegmentFigureLogic.cs
- PageContentAsyncResult.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ContainerSelectorGlyph.cs
- DnsElement.cs
- BuildManager.cs
- AliasExpr.cs
- WaitHandle.cs
- KoreanCalendar.cs
- ProfileSettingsCollection.cs
- FlowPosition.cs
- Visual3D.cs
- DataRecordInternal.cs
- NotifyParentPropertyAttribute.cs
- DbParameterHelper.cs
- OperationPerformanceCounters.cs
- StickyNoteAnnotations.cs
- RijndaelManagedTransform.cs
- SamlSerializer.cs
- OptionUsage.cs
- ManagedFilter.cs
- XPathNodeIterator.cs
- ElementHostAutomationPeer.cs
- WindowAutomationPeer.cs
- GenericsInstances.cs
- figurelength.cs
- MSG.cs
- AsymmetricKeyExchangeFormatter.cs
- FormView.cs
- DocumentCollection.cs
- ConfigXmlComment.cs
- AliasedSlot.cs
- ChangeInterceptorAttribute.cs
- QilBinary.cs
- SignedPkcs7.cs
- SimpleApplicationHost.cs
- EmbeddedObject.cs
- XmlSchemaAnnotation.cs
- MetafileHeader.cs
- ToolboxControl.cs
- SmiContextFactory.cs
- WindowsStartMenu.cs
- SqlDataSourceStatusEventArgs.cs
- CallbackException.cs
- ThreadAbortException.cs
- WebPartDeleteVerb.cs
- Vector3DCollection.cs
- safelink.cs
- SystemMulticastIPAddressInformation.cs
- ResourceSetExpression.cs
- ICspAsymmetricAlgorithm.cs
- SuppressMergeCheckAttribute.cs
- ProxyManager.cs
- ArrayWithOffset.cs
- IconBitmapDecoder.cs
- RIPEMD160Managed.cs
- DocumentXmlWriter.cs
- PlaceHolder.cs
- HttpHandlerAction.cs
- WebPartEditorOkVerb.cs
- _SpnDictionary.cs
- Rijndael.cs
- MsmqIntegrationSecurityElement.cs
- GetPageCompletedEventArgs.cs
- CodeTypeDelegate.cs
- RawKeyboardInputReport.cs
- LateBoundBitmapDecoder.cs
- DecimalKeyFrameCollection.cs
- OutOfMemoryException.cs
- SoapInteropTypes.cs
- Int64AnimationUsingKeyFrames.cs
- AppDomainEvidenceFactory.cs
- StreamReader.cs
- AutoCompleteStringCollection.cs
- AssociatedControlConverter.cs
- DoubleLink.cs
- LinkClickEvent.cs
- InputScopeConverter.cs
- PtsContext.cs
- SecureUICommand.cs
- ReachObjectContext.cs
- PeerServiceMessageContracts.cs
- SchemaTableColumn.cs
- ApplicationId.cs
- counter.cs
- CopyNamespacesAction.cs
- DataStreamFromComStream.cs
- HScrollBar.cs
- VisualTransition.cs
- storagemappingitemcollection.viewdictionary.cs
- GetWinFXPath.cs
- GenericFlowSwitchHelper.cs
- UrlMappingsModule.cs
- Module.cs
- SerializationException.cs
- ScriptRegistrationManager.cs
- RowCache.cs
- UpdateRecord.cs