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
- XsdValidatingReader.cs
- ConvertEvent.cs
- BitmapSource.cs
- PrintPreviewDialog.cs
- AsnEncodedData.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- Cursors.cs
- FilterRepeater.cs
- IntranetCredentialPolicy.cs
- cookie.cs
- XmlDataCollection.cs
- QueryRewriter.cs
- ToolStripGrip.cs
- UrlPropertyAttribute.cs
- DataPagerFieldCommandEventArgs.cs
- TemplateBindingExpression.cs
- BooleanSwitch.cs
- PropertyTabAttribute.cs
- TreeNodeEventArgs.cs
- CurrencyWrapper.cs
- CatalogZone.cs
- PagerStyle.cs
- Membership.cs
- DataSourceSelectArguments.cs
- FrameSecurityDescriptor.cs
- HttpPostedFile.cs
- ExpressionPrinter.cs
- XmlSchemaObjectCollection.cs
- SchemaUtility.cs
- CombinedGeometry.cs
- SymDocumentType.cs
- MD5CryptoServiceProvider.cs
- Visitors.cs
- MsmqAppDomainProtocolHandler.cs
- SchemaConstraints.cs
- util.cs
- AssociatedControlConverter.cs
- LongTypeConverter.cs
- CommonDialog.cs
- SafePipeHandle.cs
- UIPermission.cs
- SelectionRangeConverter.cs
- DecoderFallbackWithFailureFlag.cs
- EntityClassGenerator.cs
- DataGridViewCellValidatingEventArgs.cs
- DelegatingConfigHost.cs
- XmlSchemaGroup.cs
- EventLogPermissionHolder.cs
- MethodImplAttribute.cs
- CodeParameterDeclarationExpressionCollection.cs
- PreloadedPackages.cs
- CheckBoxRenderer.cs
- WeakReferenceKey.cs
- RunWorkerCompletedEventArgs.cs
- CompiledXpathExpr.cs
- ProcessHostMapPath.cs
- UnSafeCharBuffer.cs
- AspNetSynchronizationContext.cs
- XmlIgnoreAttribute.cs
- EventLogPermissionEntryCollection.cs
- ContentFileHelper.cs
- XmlExpressionDumper.cs
- ReaderContextStackData.cs
- InkCanvas.cs
- StateWorkerRequest.cs
- StringCollectionEditor.cs
- HyperLinkField.cs
- CompensableActivity.cs
- dsa.cs
- CircleHotSpot.cs
- NullRuntimeConfig.cs
- HttpResponseHeader.cs
- SqlIdentifier.cs
- IArgumentProvider.cs
- BindingExpressionUncommonField.cs
- DurableInstancingOptions.cs
- XsltLoader.cs
- WindowsComboBox.cs
- VariableAction.cs
- EventToken.cs
- OleDbCommandBuilder.cs
- EntryWrittenEventArgs.cs
- SiteMapDataSourceView.cs
- ConnectionManagementElement.cs
- GridEntryCollection.cs
- SqlUdtInfo.cs
- RegexReplacement.cs
- LogicalChannelCollection.cs
- PartDesigner.cs
- XmlSchemaProviderAttribute.cs
- GorillaCodec.cs
- HelpEvent.cs
- Pen.cs
- ClaimSet.cs
- OpenFileDialog.cs
- BinaryCommonClasses.cs
- WindowsTooltip.cs
- AddInBase.cs
- PropertyMapper.cs
- GuidelineSet.cs