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
- SQLDouble.cs
- EDesignUtil.cs
- XmlBinaryReader.cs
- PerformanceCounterCategory.cs
- WebConfigurationHost.cs
- CreationContext.cs
- UnsafeNativeMethodsPenimc.cs
- GroupBox.cs
- DataRowCollection.cs
- CompositeFontParser.cs
- Win32MouseDevice.cs
- ServiceNameCollection.cs
- KeyFrames.cs
- PassportAuthenticationEventArgs.cs
- StateBag.cs
- InputScope.cs
- DataSpaceManager.cs
- ReflectEventDescriptor.cs
- HtmlPhoneCallAdapter.cs
- Frame.cs
- AnimationStorage.cs
- ReadOnlyObservableCollection.cs
- SiteMapSection.cs
- UnmanagedMarshal.cs
- XmlNodeReader.cs
- RequestSecurityTokenResponse.cs
- MultiBindingExpression.cs
- HtmlTernaryTree.cs
- TimestampInformation.cs
- WeakEventManager.cs
- ETagAttribute.cs
- RegexStringValidatorAttribute.cs
- X509Certificate2.cs
- SimplePropertyEntry.cs
- OleDbConnectionInternal.cs
- SoapSchemaImporter.cs
- RectangleGeometry.cs
- DataServiceQueryProvider.cs
- RotateTransform3D.cs
- PartialCachingAttribute.cs
- RawStylusSystemGestureInputReport.cs
- ErrorHandler.cs
- UITypeEditor.cs
- IncrementalHitTester.cs
- ObjectAssociationEndMapping.cs
- StreamSecurityUpgradeAcceptor.cs
- Rules.cs
- AppSettings.cs
- ConnectionOrientedTransportManager.cs
- IERequestCache.cs
- Cursor.cs
- VisualBrush.cs
- BindingManagerDataErrorEventArgs.cs
- HealthMonitoringSectionHelper.cs
- ByteRangeDownloader.cs
- ObjectDataSourceDisposingEventArgs.cs
- Maps.cs
- ReferenceService.cs
- WebEventCodes.cs
- XmlSchemaAttribute.cs
- EndOfStreamException.cs
- HwndPanningFeedback.cs
- TypeSystemProvider.cs
- MemoryFailPoint.cs
- AddressingVersion.cs
- LicFileLicenseProvider.cs
- ModulesEntry.cs
- NumberSubstitution.cs
- SpellerStatusTable.cs
- MruCache.cs
- WebPartHelpVerb.cs
- NullableConverter.cs
- DesignerCapabilities.cs
- TabControlToolboxItem.cs
- ListView.cs
- ContentPlaceHolder.cs
- CqlLexerHelpers.cs
- BitmapEncoder.cs
- Path.cs
- cookie.cs
- SID.cs
- HttpChannelBindingToken.cs
- _NegoStream.cs
- ButtonPopupAdapter.cs
- SettingsPropertyValueCollection.cs
- SoapSchemaExporter.cs
- CapabilitiesAssignment.cs
- PriorityQueue.cs
- XPathNodeInfoAtom.cs
- Rethrow.cs
- DiagnosticsConfigurationHandler.cs
- CodeCommentStatementCollection.cs
- ComponentDispatcher.cs
- ValidateNames.cs
- DataGridViewBand.cs
- mediaeventshelper.cs
- PeerName.cs
- ValidationError.cs
- SiteMapNodeItemEventArgs.cs
- XslVisitor.cs