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
- ContainerControl.cs
- PathSegmentCollection.cs
- ExpressionVisitor.cs
- ImageInfo.cs
- DocumentOrderComparer.cs
- PolicyLevel.cs
- WorkItem.cs
- ContainerUIElement3D.cs
- MobileResource.cs
- DBSchemaTable.cs
- Pair.cs
- CollectionMarkupSerializer.cs
- ManagementEventArgs.cs
- AutoResizedEvent.cs
- Function.cs
- EdmPropertyAttribute.cs
- ZoneIdentityPermission.cs
- bidPrivateBase.cs
- _DomainName.cs
- BindingMAnagerBase.cs
- HwndHost.cs
- ErrorProvider.cs
- TableCell.cs
- BitmapFrameDecode.cs
- TextBoxDesigner.cs
- URLAttribute.cs
- SlipBehavior.cs
- XmlCharacterData.cs
- COM2ExtendedUITypeEditor.cs
- recordstatescratchpad.cs
- FastEncoder.cs
- RadioButtonAutomationPeer.cs
- StrokeNodeEnumerator.cs
- ConfigurationSettings.cs
- OdbcError.cs
- DataGrid.cs
- AsymmetricSignatureFormatter.cs
- Fonts.cs
- JapaneseCalendar.cs
- PageStatePersister.cs
- ObjectListCommandsPage.cs
- ZoneMembershipCondition.cs
- ExtentCqlBlock.cs
- ContentType.cs
- DependencyPropertyHelper.cs
- ExchangeUtilities.cs
- IndexerNameAttribute.cs
- TypedRowGenerator.cs
- QuadraticBezierSegment.cs
- XPathBinder.cs
- LookupBindingPropertiesAttribute.cs
- CodeCommentStatementCollection.cs
- BindingManagerDataErrorEventArgs.cs
- ModelFunctionTypeElement.cs
- GridViewCommandEventArgs.cs
- MouseGesture.cs
- MailDefinition.cs
- ExpressionCopier.cs
- ObjectQueryProvider.cs
- PlainXmlSerializer.cs
- WebPartCatalogCloseVerb.cs
- TypeConverterHelper.cs
- MediaElement.cs
- Camera.cs
- InputBindingCollection.cs
- DbConnectionPoolGroup.cs
- TemplateControl.cs
- TcpDuplicateContext.cs
- LinqDataSourceSelectEventArgs.cs
- XmlUtil.cs
- EntityViewGenerator.cs
- SqlParameterizer.cs
- PackageRelationshipSelector.cs
- GridEntryCollection.cs
- StorageMappingItemLoader.cs
- RichTextBoxConstants.cs
- FixedHighlight.cs
- FrameworkElement.cs
- KnownBoxes.cs
- ConnectionsZone.cs
- ServiceOperationWrapper.cs
- DataGridCell.cs
- DescendantBaseQuery.cs
- AsyncResult.cs
- RtfFormatStack.cs
- Vector3DAnimation.cs
- ConstructorBuilder.cs
- counter.cs
- DataGridViewSelectedColumnCollection.cs
- Sql8ConformanceChecker.cs
- FontStyleConverter.cs
- DataGridViewCellValidatingEventArgs.cs
- ParameterExpression.cs
- MouseDevice.cs
- HtmlTableCell.cs
- Attributes.cs
- ObjectTokenCategory.cs
- PrinterUnitConvert.cs
- QualifiedCellIdBoolean.cs
- SkinIDTypeConverter.cs