Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- AutomationPropertyInfo.cs
- SerialPinChanges.cs
- StringToken.cs
- Transform.cs
- TemplateParser.cs
- SettingsSavedEventArgs.cs
- WebPartVerbsEventArgs.cs
- ProcessRequestArgs.cs
- SafePEFileHandle.cs
- DBConcurrencyException.cs
- AsyncResult.cs
- XmlImplementation.cs
- WebContext.cs
- ToolStripArrowRenderEventArgs.cs
- LogRestartAreaEnumerator.cs
- GenericWebPart.cs
- FunctionCommandText.cs
- VirtualizingStackPanel.cs
- LogicalChannel.cs
- AnnotationComponentManager.cs
- ComponentConverter.cs
- UiaCoreApi.cs
- Tokenizer.cs
- GridItemCollection.cs
- TextTreeRootNode.cs
- RetrieveVirtualItemEventArgs.cs
- CardSpacePolicyElement.cs
- TransformedBitmap.cs
- HtmlButton.cs
- WebSysDescriptionAttribute.cs
- DiscriminatorMap.cs
- CompiledQueryCacheKey.cs
- BevelBitmapEffect.cs
- SymmetricAlgorithm.cs
- RecordBuilder.cs
- PathStreamGeometryContext.cs
- QilList.cs
- RichTextBoxAutomationPeer.cs
- ScrollContentPresenter.cs
- XmlRootAttribute.cs
- LocatorManager.cs
- SystemIPv4InterfaceProperties.cs
- ReadWriteObjectLock.cs
- JournalEntry.cs
- Directory.cs
- GridViewPageEventArgs.cs
- SchemaNamespaceManager.cs
- MediaElement.cs
- safex509handles.cs
- XamlFilter.cs
- RawMouseInputReport.cs
- DataContractSet.cs
- TextServicesManager.cs
- XmlAttributeOverrides.cs
- OleDbCommand.cs
- ThreadPool.cs
- SqlDataReader.cs
- RenamedEventArgs.cs
- SystemIcmpV6Statistics.cs
- LayoutDump.cs
- XmlSignatureProperties.cs
- Label.cs
- ReferenceConverter.cs
- ConvertersCollection.cs
- HttpResponseHeader.cs
- RevocationPoint.cs
- XsltCompileContext.cs
- OdbcConnectionPoolProviderInfo.cs
- ApplicationFileParser.cs
- Point3DAnimationUsingKeyFrames.cs
- OutputCacheSettingsSection.cs
- DynamicMethod.cs
- HttpStreamFormatter.cs
- WCFBuildProvider.cs
- JsonFormatWriterGenerator.cs
- XmlSchemaAttribute.cs
- VirtualPathUtility.cs
- ProfileProvider.cs
- ToolboxItemLoader.cs
- BufferedWebEventProvider.cs
- ObjectDataSourceStatusEventArgs.cs
- StringFreezingAttribute.cs
- RegexWriter.cs
- ResXFileRef.cs
- Splitter.cs
- DBProviderConfigurationHandler.cs
- SmiMetaData.cs
- CacheDependency.cs
- WindowsFont.cs
- IgnoreFileBuildProvider.cs
- DynamicILGenerator.cs
- PtsContext.cs
- CompModSwitches.cs
- RepeatButtonAutomationPeer.cs
- CustomValidator.cs
- ResourceReferenceExpression.cs
- HttpsChannelFactory.cs
- OleDbFactory.cs
- ViewLoader.cs
- StandardOleMarshalObject.cs