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
- FixedPageAutomationPeer.cs
- Subset.cs
- DBConnection.cs
- DefaultDialogButtons.cs
- DataGridViewTextBoxColumn.cs
- PopupControlService.cs
- StdValidatorsAndConverters.cs
- GeometryGroup.cs
- DifferencingCollection.cs
- WebPartZone.cs
- ComponentCollection.cs
- RootAction.cs
- ScriptManager.cs
- MenuBase.cs
- InternalTransaction.cs
- DoubleUtil.cs
- COAUTHINFO.cs
- FilterException.cs
- ToolStripDropDownItemDesigner.cs
- MetadataCollection.cs
- XmlSchemaInferenceException.cs
- SqlProfileProvider.cs
- SessionStateSection.cs
- ProviderMetadata.cs
- PartialCachingControl.cs
- DragSelectionMessageFilter.cs
- FunctionNode.cs
- Deserializer.cs
- VariantWrapper.cs
- TimeSpanMinutesConverter.cs
- ListViewGroupConverter.cs
- CalendarTable.cs
- GifBitmapEncoder.cs
- TreeViewItem.cs
- XhtmlTextWriter.cs
- WebServiceAttribute.cs
- LocationSectionRecord.cs
- ImageDrawing.cs
- PropertyEmitter.cs
- DynamicUpdateCommand.cs
- ColumnResizeUndoUnit.cs
- ParallelEnumerable.cs
- IntegerValidatorAttribute.cs
- X509CertificateClaimSet.cs
- ZipIOExtraFieldZip64Element.cs
- AuditLog.cs
- MultipleViewPatternIdentifiers.cs
- WmfPlaceableFileHeader.cs
- WebReferenceOptions.cs
- StrongNameHelpers.cs
- RadioButtonRenderer.cs
- SuppressIldasmAttribute.cs
- ComponentEditorForm.cs
- DeferredTextReference.cs
- PartialCachingControl.cs
- PageRanges.cs
- PrePrepareMethodAttribute.cs
- ExpressionEditorAttribute.cs
- CLRBindingWorker.cs
- DataGridHeaderBorder.cs
- JpegBitmapDecoder.cs
- ItemsChangedEventArgs.cs
- DataGridViewButtonColumn.cs
- sqlpipe.cs
- XmlElementAttributes.cs
- DataBoundControlAdapter.cs
- CodeChecksumPragma.cs
- DynamicDocumentPaginator.cs
- ReachDocumentReferenceSerializer.cs
- DocumentsTrace.cs
- ExceptionNotification.cs
- FilterElement.cs
- FormatVersion.cs
- ServiceOperationWrapper.cs
- EventLogReader.cs
- FreeFormDragDropManager.cs
- MailSettingsSection.cs
- PageThemeCodeDomTreeGenerator.cs
- DataSetUtil.cs
- SqlCacheDependencyDatabase.cs
- IgnoreSectionHandler.cs
- ResourceDisplayNameAttribute.cs
- counter.cs
- SqlConnectionString.cs
- CodeCommentStatement.cs
- MoveSizeWinEventHandler.cs
- HttpEncoderUtility.cs
- CollectionBase.cs
- XmlSchemaAttribute.cs
- DbQueryCommandTree.cs
- PropVariant.cs
- _AutoWebProxyScriptEngine.cs
- RowSpanVector.cs
- AstTree.cs
- EastAsianLunisolarCalendar.cs
- ScrollData.cs
- RadioButtonAutomationPeer.cs
- ConfigXmlCDataSection.cs
- Int16.cs
- OlePropertyStructs.cs