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
- ReliableSessionElement.cs
- FontFamilyIdentifier.cs
- PropertyChangedEventManager.cs
- MarkupObject.cs
- RowSpanVector.cs
- DataGridColumnCollection.cs
- ResourceDescriptionAttribute.cs
- SrgsRuleRef.cs
- SrgsElementFactoryCompiler.cs
- Win32Native.cs
- PropertyTabAttribute.cs
- PageThemeParser.cs
- ErrorStyle.cs
- SoapIncludeAttribute.cs
- MULTI_QI.cs
- GridViewCommandEventArgs.cs
- ContentFilePart.cs
- MinimizableAttributeTypeConverter.cs
- TextInfo.cs
- Enlistment.cs
- DesignerSelectionListAdapter.cs
- XmlSchemaSequence.cs
- SqlBooleanMismatchVisitor.cs
- sqlmetadatafactory.cs
- MapPathBasedVirtualPathProvider.cs
- OracleDateTime.cs
- ExecutedRoutedEventArgs.cs
- DependencyPropertyDescriptor.cs
- UIntPtr.cs
- OperationAbortedException.cs
- Knowncolors.cs
- UpdateException.cs
- Property.cs
- ADMembershipUser.cs
- ALinqExpressionVisitor.cs
- PictureBox.cs
- MimeObjectFactory.cs
- TableRowsCollectionEditor.cs
- ImageCodecInfo.cs
- OlePropertyStructs.cs
- ListControl.cs
- PropertyGroupDescription.cs
- CommonDialog.cs
- OpenCollectionAsyncResult.cs
- RenderCapability.cs
- HttpAsyncResult.cs
- XmlNodeWriter.cs
- PriorityRange.cs
- LogAppendAsyncResult.cs
- ProcessHost.cs
- BuildResult.cs
- Lock.cs
- ReflectionHelper.cs
- UIEndRequest.cs
- Connector.cs
- ConfigurationValues.cs
- ComboBoxItem.cs
- __Error.cs
- LineSegment.cs
- SQLStringStorage.cs
- CfgArc.cs
- CheckedListBox.cs
- AutomationProperty.cs
- SHA256.cs
- CaseStatementProjectedSlot.cs
- XmlSchemaExporter.cs
- WebPartZoneCollection.cs
- ShortcutKeysEditor.cs
- ValidatorCollection.cs
- MatrixKeyFrameCollection.cs
- DbDataAdapter.cs
- TokenBasedSetEnumerator.cs
- TextEditorContextMenu.cs
- ColorInterpolationModeValidation.cs
- TransactionWaitAsyncResult.cs
- FigureHelper.cs
- CommentEmitter.cs
- Literal.cs
- DataSourceXmlClassAttribute.cs
- ImageIndexConverter.cs
- ContainerParaClient.cs
- PolicyValidationException.cs
- GridViewCellAutomationPeer.cs
- ConnectionManagementSection.cs
- TemplateControlParser.cs
- NavigatorInput.cs
- KeyTimeConverter.cs
- FormViewInsertEventArgs.cs
- ContentDefinition.cs
- ComponentConverter.cs
- DataReceivedEventArgs.cs
- ScopedKnownTypes.cs
- TextAction.cs
- MatrixTransform.cs
- CompilerCollection.cs
- ActivationServices.cs
- EventDescriptor.cs
- Debug.cs
- WebBrowser.cs
- XmlObjectSerializerReadContext.cs