Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Channels / System / ServiceModel / Channels / XmlBufferedByteStreamReader.cs / 1305376 / XmlBufferedByteStreamReader.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System; using System.IO; using System.Runtime; using System.Xml; class XmlBufferedByteStreamReader : XmlByteStreamReader { ByteStreamBufferedMessageData bufferedMessageData; int offset; static byte[] emptyByteArray = new byte[0]; public XmlBufferedByteStreamReader(ByteStreamBufferedMessageData bufferedMessageData, XmlDictionaryReaderQuotas quotas) : base (quotas) { Fx.Assert(bufferedMessageData != null, "bufferedMessageData is null"); this.bufferedMessageData = bufferedMessageData; this.bufferedMessageData.Open(); this.offset = 0; this.quotas = quotas; this.position = ReaderPosition.None; } protected override void OnClose() { this.bufferedMessageData.Close(); this.bufferedMessageData = null; this.offset = 0; base.OnClose(); } public override int ReadContentAsBase64(byte[] buffer, int index, int count) { EnsureInContent(); ByteStreamMessageUtility.EnsureByteBoundaries(buffer, index, count); if (count == 0) { return 0; } int bytesToCopy = Math.Min(bufferedMessageData.Count - this.offset, count); if (bytesToCopy == 0) { this.position = ReaderPosition.EndElement; return 0; } Buffer.BlockCopy(this.bufferedMessageData.Buffer, this.offset, buffer, index, bytesToCopy); this.offset += bytesToCopy; return bytesToCopy; } public override bool TryGetBase64ContentLength(out int length) { if (!this.IsClosed) { // in ByteStream encoder, we're not concerned about individual xml nodes // therefore we can just return the entire segment of the buffer we're using in this reader. length = bufferedMessageData.Count; return true; } length = -1; return false; } } } // 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
- TempFiles.cs
- MultiDataTrigger.cs
- PenContexts.cs
- DocumentPage.cs
- MobileRedirect.cs
- ActivationArguments.cs
- WebPartConnectionCollection.cs
- ProfileService.cs
- WindowsFormsLinkLabel.cs
- Rotation3DAnimation.cs
- DrawTreeNodeEventArgs.cs
- GlyphsSerializer.cs
- Clipboard.cs
- XmlSchemaAttribute.cs
- RIPEMD160Managed.cs
- WebBrowsableAttribute.cs
- TemplateControlParser.cs
- WebPartDisplayModeCancelEventArgs.cs
- SaveFileDialog.cs
- PropertyEntry.cs
- SystemIPv4InterfaceProperties.cs
- SafeRegistryKey.cs
- AttributeExtensions.cs
- KeyedCollection.cs
- ElementNotAvailableException.cs
- HistoryEventArgs.cs
- DataGridItem.cs
- PagesSection.cs
- ControlBuilderAttribute.cs
- TemplateBamlTreeBuilder.cs
- Transform3DGroup.cs
- NetCodeGroup.cs
- UnsafeCollabNativeMethods.cs
- CustomAttributeFormatException.cs
- StringUtil.cs
- NestPullup.cs
- WorkBatch.cs
- CatalogZone.cs
- WebBrowsableAttribute.cs
- HtmlElementErrorEventArgs.cs
- LineInfo.cs
- CacheMemory.cs
- FontSizeConverter.cs
- ApplicationDirectory.cs
- Tablet.cs
- WasNotInstalledException.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- VerificationException.cs
- CodeAttributeArgument.cs
- StrokeSerializer.cs
- ExtensionDataReader.cs
- ActivationArguments.cs
- DataGridViewCellFormattingEventArgs.cs
- Table.cs
- InfoCardTrace.cs
- AssemblyCollection.cs
- XomlSerializationHelpers.cs
- FlowDecisionLabelFeature.cs
- BaseDataListPage.cs
- CodeEventReferenceExpression.cs
- SystemUnicastIPAddressInformation.cs
- LoadGrammarCompletedEventArgs.cs
- Sentence.cs
- StreamResourceInfo.cs
- MediaPlayer.cs
- HttpCacheVaryByContentEncodings.cs
- NetTcpSecurityElement.cs
- ObjectDataSourceChooseMethodsPanel.cs
- AnnotationDocumentPaginator.cs
- DesignTimeData.cs
- GuidConverter.cs
- DesignerActionMethodItem.cs
- DockPattern.cs
- ValidationHelper.cs
- ConfigLoader.cs
- ZipIOModeEnforcingStream.cs
- ClockController.cs
- itemelement.cs
- AppAction.cs
- SerializationHelper.cs
- securitycriticaldataClass.cs
- EncodingDataItem.cs
- IntSecurity.cs
- FlowDocumentReader.cs
- RunClient.cs
- SortExpressionBuilder.cs
- OrderedDictionary.cs
- PropertyValueChangedEvent.cs
- RectValueSerializer.cs
- DynamicArgumentDesigner.xaml.cs
- CodeDesigner.cs
- ObjectDataSourceDisposingEventArgs.cs
- DebuggerAttributes.cs
- XmlSchemaAny.cs
- HttpTransportManager.cs
- ApplicationId.cs
- GcHandle.cs
- ConnectionPoint.cs
- Missing.cs
- SystemGatewayIPAddressInformation.cs