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
- WebBrowserUriTypeConverter.cs
- ReadOnlyHierarchicalDataSource.cs
- EnumBuilder.cs
- FullTrustAssembliesSection.cs
- XmlExtensionFunction.cs
- ScriptIgnoreAttribute.cs
- ReflectionPermission.cs
- MemberInfoSerializationHolder.cs
- PointAnimationUsingPath.cs
- XmlDataDocument.cs
- Paragraph.cs
- mansign.cs
- LazyTextWriterCreator.cs
- CurrencyWrapper.cs
- SoapHeaderException.cs
- PageEventArgs.cs
- ModelServiceImpl.cs
- StaticExtensionConverter.cs
- path.cs
- EngineSiteSapi.cs
- WSHttpSecurityElement.cs
- PolyQuadraticBezierSegment.cs
- FormViewDeletedEventArgs.cs
- SID.cs
- DataDesignUtil.cs
- MDIClient.cs
- ErrorRuntimeConfig.cs
- XmlArrayItemAttribute.cs
- ToolStripPanelCell.cs
- MailMessage.cs
- JumpItem.cs
- SendingRequestEventArgs.cs
- FontDialog.cs
- WorkerRequest.cs
- OdbcHandle.cs
- Method.cs
- InvalidStoreProtectionKeyException.cs
- FrameSecurityDescriptor.cs
- DataGridViewTextBoxCell.cs
- HtmlValidationSummaryAdapter.cs
- AuthorizationRule.cs
- ForwardPositionQuery.cs
- PopOutPanel.cs
- ReadWriteSpinLock.cs
- TypeConverterValueSerializer.cs
- MetafileHeaderWmf.cs
- ContextInformation.cs
- SecurityHelper.cs
- Opcode.cs
- lengthconverter.cs
- ListCollectionView.cs
- HtmlInputText.cs
- CompositeCollectionView.cs
- SurrogateSelector.cs
- ForeignKeyConstraint.cs
- MethodExpression.cs
- SelectingProviderEventArgs.cs
- DataSetFieldSchema.cs
- GridViewColumn.cs
- HttpsHostedTransportConfiguration.cs
- Rotation3DKeyFrameCollection.cs
- cookie.cs
- TypedTableBaseExtensions.cs
- WebConfigurationHostFileChange.cs
- sqlpipe.cs
- SqlNodeAnnotations.cs
- XmlDocument.cs
- processwaithandle.cs
- StandardMenuStripVerb.cs
- XmlSchemaAttribute.cs
- TextDecorationUnitValidation.cs
- PropertyGridCommands.cs
- SQLDateTimeStorage.cs
- BooleanFacetDescriptionElement.cs
- SettingsProperty.cs
- ClientOperationFormatterProvider.cs
- OleCmdHelper.cs
- GradientStop.cs
- VScrollBar.cs
- CommonGetThemePartSize.cs
- ToolStripDropDownDesigner.cs
- BindingNavigatorDesigner.cs
- DataProviderNameConverter.cs
- GeneralTransformCollection.cs
- QueryStringParameter.cs
- LogSwitch.cs
- StatusBarAutomationPeer.cs
- StackOverflowException.cs
- ServerValidateEventArgs.cs
- CollectionType.cs
- RegexTree.cs
- DataMember.cs
- SqlRewriteScalarSubqueries.cs
- System.Data.OracleClient_BID.cs
- SelectingProviderEventArgs.cs
- TextContainerHelper.cs
- PerformanceCounter.cs
- TypeDescriptionProvider.cs
- ConfigXmlReader.cs
- GridViewCancelEditEventArgs.cs