Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- DockAndAnchorLayout.cs
- TextComposition.cs
- TreeNode.cs
- UnlockInstanceAsyncResult.cs
- ColorAnimationUsingKeyFrames.cs
- DataFormat.cs
- Schema.cs
- ToolStripMenuItemDesigner.cs
- ButtonChrome.cs
- EmbeddedMailObject.cs
- LinqDataSource.cs
- CodeGenerator.cs
- EntityDataSourceColumn.cs
- WinEventWrap.cs
- Stream.cs
- exports.cs
- XmlMapping.cs
- Int64.cs
- MultiBindingExpression.cs
- _ConnectOverlappedAsyncResult.cs
- TimeSpanSecondsConverter.cs
- NonBatchDirectoryCompiler.cs
- TransactionChannel.cs
- IdentityHolder.cs
- DrawingGroup.cs
- OleDbStruct.cs
- Cursors.cs
- IpcServerChannel.cs
- WebPartVerbCollection.cs
- FontFamilyConverter.cs
- HttpConfigurationSystem.cs
- SqlFacetAttribute.cs
- ObjectRef.cs
- EncodingDataItem.cs
- Privilege.cs
- ArcSegment.cs
- DataSourceCacheDurationConverter.cs
- OleDbStruct.cs
- SecurityContext.cs
- DataStreams.cs
- Int32Storage.cs
- Point3DKeyFrameCollection.cs
- GridViewPageEventArgs.cs
- QualifiedCellIdBoolean.cs
- DataViewSettingCollection.cs
- MetadataCacheItem.cs
- Visitor.cs
- IncrementalCompileAnalyzer.cs
- DocumentXmlWriter.cs
- LineProperties.cs
- ItemContainerGenerator.cs
- EasingKeyFrames.cs
- PropertyGridEditorPart.cs
- Pkcs7Recipient.cs
- TraceRecord.cs
- MouseButton.cs
- EntityDataSourceContextDisposingEventArgs.cs
- ISFClipboardData.cs
- XmlElement.cs
- CustomAssemblyResolver.cs
- diagnosticsswitches.cs
- WindowsSysHeader.cs
- DataGridViewComboBoxCell.cs
- StrongName.cs
- TreeIterator.cs
- PreviewPrintController.cs
- AnnotationMap.cs
- UiaCoreTypesApi.cs
- ViewBox.cs
- PassportIdentity.cs
- ProgressBarHighlightConverter.cs
- Size3D.cs
- StaticFileHandler.cs
- HwndProxyElementProvider.cs
- ElementNotEnabledException.cs
- ToolStripOverflowButton.cs
- WmlListAdapter.cs
- WindowsTitleBar.cs
- dataobject.cs
- Console.cs
- EntityCommand.cs
- AssociationType.cs
- PerformanceCounterPermissionEntry.cs
- InputReferenceExpression.cs
- DependencyPropertyValueSerializer.cs
- FrameworkObject.cs
- Application.cs
- GeneralTransformGroup.cs
- propertytag.cs
- DbRetry.cs
- TransportConfigurationTypeElement.cs
- StylusPlugin.cs
- FixedSOMGroup.cs
- PeerPresenceInfo.cs
- UnmanagedHandle.cs
- DuplexChannelBinder.cs
- Internal.cs
- SHA256.cs
- ButtonBase.cs
- RadioButtonList.cs