Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / TextSerializer.cs / 1305376 / 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
- XmlSchemaSimpleTypeUnion.cs
- Roles.cs
- ChannelAcceptor.cs
- TypeForwardedToAttribute.cs
- ArrayConverter.cs
- RoutedEvent.cs
- TextViewSelectionProcessor.cs
- ParallelLoopState.cs
- COM2PictureConverter.cs
- Serializer.cs
- FacetValues.cs
- ObjectViewListener.cs
- WindowsAuthenticationModule.cs
- DispatcherFrame.cs
- ServiceHostFactory.cs
- SiteMapSection.cs
- ReachPrintTicketSerializer.cs
- Expressions.cs
- Image.cs
- TextControlDesigner.cs
- DoubleLink.cs
- DayRenderEvent.cs
- Point.cs
- GB18030Encoding.cs
- BitmapEncoder.cs
- RequestCacheEntry.cs
- DispatcherExceptionEventArgs.cs
- StoryFragments.cs
- TableLayoutSettings.cs
- HostingEnvironmentSection.cs
- BaseCAMarshaler.cs
- RuntimeConfigurationRecord.cs
- ToolStripDropTargetManager.cs
- Guid.cs
- SerializationFieldInfo.cs
- DispatcherEventArgs.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- FillErrorEventArgs.cs
- RuleRefElement.cs
- DataGridViewCheckBoxCell.cs
- WebExceptionStatus.cs
- InvalidComObjectException.cs
- AssemblyBuilder.cs
- TdsRecordBufferSetter.cs
- TabPage.cs
- UIElementCollection.cs
- DesignerAdapterAttribute.cs
- ContainsSearchOperator.cs
- DataQuery.cs
- DbProviderFactories.cs
- FormatterServices.cs
- GatewayDefinition.cs
- XmlWellformedWriter.cs
- StorageScalarPropertyMapping.cs
- EventSinkActivityDesigner.cs
- ObjectSet.cs
- XmlTypeAttribute.cs
- __Filters.cs
- ContentTextAutomationPeer.cs
- TemplateField.cs
- OleDbDataAdapter.cs
- GlobalProxySelection.cs
- BaseHashHelper.cs
- RectangleGeometry.cs
- UpdateTracker.cs
- FormViewDeletedEventArgs.cs
- MultiTargetingUtil.cs
- SpAudioStreamWrapper.cs
- ISAPIRuntime.cs
- EventDescriptorCollection.cs
- RoleGroup.cs
- DataSourceXmlClassAttribute.cs
- PasswordDeriveBytes.cs
- AnnotationResource.cs
- UrlPropertyAttribute.cs
- XmlSchemaAppInfo.cs
- ZoneMembershipCondition.cs
- MethodBuilderInstantiation.cs
- AssemblyBuilder.cs
- PointIndependentAnimationStorage.cs
- CreateUserWizardStep.cs
- EventLogStatus.cs
- ListViewItemEventArgs.cs
- TableProvider.cs
- KnownTypesProvider.cs
- BoundPropertyEntry.cs
- DataServiceQuery.cs
- PrintPreviewDialog.cs
- XmlObjectSerializerReadContextComplex.cs
- StringStorage.cs
- ConnectionPoolManager.cs
- RC2CryptoServiceProvider.cs
- LineServicesRun.cs
- AsyncDataRequest.cs
- HttpRequestMessageProperty.cs
- StickyNoteContentControl.cs
- HttpCookiesSection.cs
- HttpProcessUtility.cs
- ComponentRenameEvent.cs
- MDIClient.cs