Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- MultipartContentParser.cs
- LassoHelper.cs
- PolicyUnit.cs
- controlskin.cs
- DesignTimeHTMLTextWriter.cs
- Margins.cs
- DataGridViewRowConverter.cs
- MetaType.cs
- CodeVariableReferenceExpression.cs
- ListSortDescriptionCollection.cs
- EndpointDispatcherTable.cs
- UrlParameterWriter.cs
- SecurityDescriptor.cs
- RegexInterpreter.cs
- ValueSerializerAttribute.cs
- DynamicDataExtensions.cs
- StringPropertyBuilder.cs
- ScrollChangedEventArgs.cs
- XhtmlTextWriter.cs
- SpinWait.cs
- DiscardableAttribute.cs
- ContractBase.cs
- SecureStringHasher.cs
- TextSerializer.cs
- XMLSyntaxException.cs
- WorkingDirectoryEditor.cs
- XmlSchemaFacet.cs
- HyperLinkColumn.cs
- FilteredAttributeCollection.cs
- DBSqlParserColumn.cs
- AuthenticationModuleElementCollection.cs
- MetadataItemCollectionFactory.cs
- XmlNotation.cs
- OleDbCommand.cs
- AssemblyNameProxy.cs
- HyperLinkDesigner.cs
- RawStylusInputCustomDataList.cs
- DbConnectionPoolGroup.cs
- WCFServiceClientProxyGenerator.cs
- XPathScanner.cs
- BrowserTree.cs
- EntitySetBaseCollection.cs
- DiagnosticsConfigurationHandler.cs
- EnumConverter.cs
- VariableValue.cs
- UpdateCompiler.cs
- CallContext.cs
- UiaCoreProviderApi.cs
- InvalidProgramException.cs
- SendMailErrorEventArgs.cs
- ModelUtilities.cs
- ClientBuildManagerCallback.cs
- Parser.cs
- ManagedFilter.cs
- SelectionWordBreaker.cs
- HttpClientCertificate.cs
- ListenDesigner.cs
- CultureInfoConverter.cs
- ValueUnavailableException.cs
- EntityContainer.cs
- TypeBrowser.xaml.cs
- ClosableStream.cs
- ObjectItemCollection.cs
- AttachedAnnotationChangedEventArgs.cs
- FileDialog.cs
- EntityStoreSchemaFilterEntry.cs
- SmiGettersStream.cs
- CodeGeneratorAttribute.cs
- CompilerInfo.cs
- Schedule.cs
- RoleManagerEventArgs.cs
- OleDbEnumerator.cs
- XPathQueryGenerator.cs
- ClientSettingsSection.cs
- EventBookmark.cs
- TableColumn.cs
- ReadOnlyHierarchicalDataSourceView.cs
- TextDecoration.cs
- LayoutUtils.cs
- DebugHandleTracker.cs
- ArithmeticException.cs
- QuadraticEase.cs
- QuestionEventArgs.cs
- PublishLicense.cs
- DataGridCellsPanel.cs
- AnimatedTypeHelpers.cs
- CombinedGeometry.cs
- DataGridColumnHeadersPresenter.cs
- Serialization.cs
- MergeFailedEvent.cs
- DataGridRow.cs
- PropertyItemInternal.cs
- TextEndOfSegment.cs
- OleAutBinder.cs
- Menu.cs
- MultipleFilterMatchesException.cs
- DatasetMethodGenerator.cs
- DynamicPropertyHolder.cs
- XsltException.cs
- EncodingNLS.cs