Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //[....] //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpBufferlessInputStream.cs
- DaylightTime.cs
- ExpressionBindingCollection.cs
- Transform.cs
- Visual3D.cs
- WeakEventManager.cs
- TextTreeObjectNode.cs
- BinarySerializer.cs
- UserControl.cs
- BitmapEffectGroup.cs
- TextChange.cs
- XamlToRtfWriter.cs
- FrameworkElement.cs
- PopOutPanel.cs
- AffineTransform3D.cs
- NonDualMessageSecurityOverHttp.cs
- DoWorkEventArgs.cs
- InlinedAggregationOperatorEnumerator.cs
- SourceLineInfo.cs
- CategoryAttribute.cs
- BindingCollectionElement.cs
- TimelineGroup.cs
- RequestCachingSection.cs
- DrawingGroup.cs
- TypeResolver.cs
- TraceXPathNavigator.cs
- SqlCommandSet.cs
- NavigationPropertyEmitter.cs
- ToolStripSplitButton.cs
- ObjectCache.cs
- TableLayoutRowStyleCollection.cs
- TargetControlTypeCache.cs
- SqlTriggerAttribute.cs
- BitmapImage.cs
- HtmlEmptyTagControlBuilder.cs
- ChtmlTextWriter.cs
- HtmlProps.cs
- BevelBitmapEffect.cs
- dbdatarecord.cs
- SoapException.cs
- SspiHelper.cs
- CheckoutException.cs
- ControlUtil.cs
- Gdiplus.cs
- ReferentialConstraint.cs
- MetadataProperty.cs
- HtmlString.cs
- TypeSemantics.cs
- BCLDebug.cs
- MimeReturn.cs
- FixedDocumentSequencePaginator.cs
- SendingRequestEventArgs.cs
- MustUnderstandSoapException.cs
- AtomContentProperty.cs
- PropertyDescriptor.cs
- DataBindingHandlerAttribute.cs
- CompatibleIComparer.cs
- TdsEnums.cs
- KeyPressEvent.cs
- TypeForwardedToAttribute.cs
- XmlNamespaceDeclarationsAttribute.cs
- WeakHashtable.cs
- ScrollEvent.cs
- DBConnectionString.cs
- DataGridViewSelectedRowCollection.cs
- RoutedEventHandlerInfo.cs
- GlyphRunDrawing.cs
- AesManaged.cs
- DateTimeParse.cs
- Selector.cs
- InheritanceRules.cs
- TextMetrics.cs
- TextModifierScope.cs
- MtomMessageEncodingElement.cs
- ScopeCompiler.cs
- XmlIncludeAttribute.cs
- SqlAggregateChecker.cs
- ByteAnimation.cs
- SystemWebCachingSectionGroup.cs
- ConditionalDesigner.cs
- MessageDecoder.cs
- As.cs
- ComponentChangedEvent.cs
- NumberFunctions.cs
- SelectionChangedEventArgs.cs
- Delay.cs
- HtmlControlPersistable.cs
- Line.cs
- DbProviderConfigurationHandler.cs
- BaseTemplateParser.cs
- SecurityManager.cs
- X500Name.cs
- WebScriptMetadataMessageEncoderFactory.cs
- FaultImportOptions.cs
- ToolStripDropTargetManager.cs
- CustomGrammar.cs
- BinaryObjectInfo.cs
- PageCache.cs
- DynamicRendererThreadManager.cs
- PageBuildProvider.cs