Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / TextSerializer.cs / 1 / TextSerializer.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a serializer for text content. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { #region Namespaces. using System.Diagnostics; using System.IO; using System.Text; using System.Xml; #endregion Namespaces. ////// Provides support for serializing responses in text format. /// internal struct TextSerializer : IExceptionWriter { ///Writer to which output is sent. private readonly TextWriter writer; ///Initializes a new /// Stream to which output should be sent. /// Encoding to be used to write the result. internal TextSerializer(Stream output, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(encoding != null, "encoding != null"); this.writer = new StreamWriter(output, encoding); } ///for the specified stream. Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { XmlWriter xmlWriter = XmlWriter.Create(this.writer); ErrorHandler.SerializeXmlError(args, xmlWriter); this.writer.Flush(); } ///Handles the complete serialization for the specified content. /// Single Content to write.. ///internal void WriteRequest(object content) { Debug.Assert(content != null, "content != null"); string contentAsText; if (!System.Data.Services.Parsing.WebConvert.TryXmlPrimitiveToString(content, out contentAsText)) { throw new InvalidOperationException(Strings.Serializer_CannotConvertValue(content)); } Debug.Assert(contentAsText != null, "contentAsText != null"); this.writer.Write(contentAsText); this.writer.Flush(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // should be a byte array. // Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a serializer for text content. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { #region Namespaces. using System.Diagnostics; using System.IO; using System.Text; using System.Xml; #endregion Namespaces. ////// Provides support for serializing responses in text format. /// internal struct TextSerializer : IExceptionWriter { ///Writer to which output is sent. private readonly TextWriter writer; ///Initializes a new /// Stream to which output should be sent. /// Encoding to be used to write the result. internal TextSerializer(Stream output, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(encoding != null, "encoding != null"); this.writer = new StreamWriter(output, encoding); } ///for the specified stream. Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { XmlWriter xmlWriter = XmlWriter.Create(this.writer); ErrorHandler.SerializeXmlError(args, xmlWriter); this.writer.Flush(); } ///Handles the complete serialization for the specified content. /// Single Content to write.. ///internal void WriteRequest(object content) { Debug.Assert(content != null, "content != null"); string contentAsText; if (!System.Data.Services.Parsing.WebConvert.TryXmlPrimitiveToString(content, out contentAsText)) { throw new InvalidOperationException(Strings.Serializer_CannotConvertValue(content)); } Debug.Assert(contentAsText != null, "contentAsText != null"); this.writer.Write(contentAsText); this.writer.Flush(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. should be a byte array.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Debug.cs
- EntitySetBaseCollection.cs
- DetailsViewRowCollection.cs
- ServiceObjectContainer.cs
- ConfigurationLocation.cs
- Grid.cs
- PrintDocument.cs
- BaseTemplateBuildProvider.cs
- StringArrayConverter.cs
- ParameterCollection.cs
- SemaphoreSecurity.cs
- StackSpiller.Temps.cs
- SmtpDigestAuthenticationModule.cs
- TemplateContainer.cs
- FrameworkObject.cs
- PolyBezierSegmentFigureLogic.cs
- TypeResolver.cs
- ToolStripSeparatorRenderEventArgs.cs
- SerializationFieldInfo.cs
- Compilation.cs
- CssClassPropertyAttribute.cs
- TileBrush.cs
- OdbcConnectionHandle.cs
- WebPartTracker.cs
- DisplayNameAttribute.cs
- BaseProcessProtocolHandler.cs
- EntitySetDataBindingList.cs
- MaskInputRejectedEventArgs.cs
- TickBar.cs
- CreateUserWizardStep.cs
- DataGridViewLayoutData.cs
- ReceiveMessageRecord.cs
- Semaphore.cs
- XmlFormatExtensionAttribute.cs
- SystemIPAddressInformation.cs
- DictionaryEntry.cs
- SafeNativeMethods.cs
- UserControlFileEditor.cs
- DataProtection.cs
- BitmapSourceSafeMILHandle.cs
- ClientTargetCollection.cs
- XamlRtfConverter.cs
- FrameworkPropertyMetadata.cs
- DesignerTransaction.cs
- MSAAWinEventWrap.cs
- ValueConversionAttribute.cs
- WindowsListViewScroll.cs
- DecoderBestFitFallback.cs
- Ops.cs
- DeploymentExceptionMapper.cs
- ArgumentDesigner.xaml.cs
- BitmapSource.cs
- TrackingMemoryStreamFactory.cs
- BoundField.cs
- JournalEntryStack.cs
- AccessKeyManager.cs
- Underline.cs
- EventBindingService.cs
- MembershipValidatePasswordEventArgs.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- XmlDomTextWriter.cs
- SecurityTokenSerializer.cs
- SymbolMethod.cs
- ImageAnimator.cs
- DrawingAttributesDefaultValueFactory.cs
- ReadOnlyMetadataCollection.cs
- ClientSettingsProvider.cs
- GridViewRowEventArgs.cs
- SafeViewOfFileHandle.cs
- ComponentEditorPage.cs
- RealizationDrawingContextWalker.cs
- FixedDSBuilder.cs
- CompiledQuery.cs
- AppManager.cs
- AnyReturnReader.cs
- ConnectionString.cs
- XPathSelectionIterator.cs
- MetadataItemEmitter.cs
- DefaultShape.cs
- HtmlTableCell.cs
- CanExecuteRoutedEventArgs.cs
- PrivateFontCollection.cs
- DelegatingHeader.cs
- SystemWebExtensionsSectionGroup.cs
- OleDbConnection.cs
- VectorConverter.cs
- WorkflowView.cs
- PrintPreviewControl.cs
- Accessible.cs
- DispatcherSynchronizationContext.cs
- Schema.cs
- AttachedPropertyInfo.cs
- SettingsProviderCollection.cs
- LessThan.cs
- WindowsSysHeader.cs
- AsmxEndpointPickerExtension.cs
- XsdValidatingReader.cs
- SignedInfo.cs
- SmtpClient.cs
- PrimarySelectionGlyph.cs