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
- base64Transforms.cs
- PeerNameRecord.cs
- AppSettingsExpressionBuilder.cs
- OracleBFile.cs
- DesignerCategoryAttribute.cs
- FormattedText.cs
- ManipulationDelta.cs
- CallbackWrapper.cs
- PngBitmapDecoder.cs
- VectorCollection.cs
- MSAAEventDispatcher.cs
- ScriptResourceMapping.cs
- HwndSourceParameters.cs
- AutomationPattern.cs
- ITreeGenerator.cs
- TemplateKey.cs
- XomlSerializationHelpers.cs
- SpeakInfo.cs
- DiscoveryClientElement.cs
- LessThanOrEqual.cs
- SiteMapNodeItemEventArgs.cs
- SByteConverter.cs
- Pointer.cs
- SqlFileStream.cs
- TrackingProfileSerializer.cs
- DesignerActionTextItem.cs
- EntityConnectionStringBuilder.cs
- DataGridViewControlCollection.cs
- PeerInputChannel.cs
- DataBindingHandlerAttribute.cs
- __ConsoleStream.cs
- ListViewUpdateEventArgs.cs
- SqlMethods.cs
- BufferedGraphics.cs
- NegatedCellConstant.cs
- Environment.cs
- IdnMapping.cs
- ContentHostHelper.cs
- SelectionListDesigner.cs
- ComplexPropertyEntry.cs
- X509Certificate2.cs
- ZoneIdentityPermission.cs
- XmlUTF8TextReader.cs
- WindowsContainer.cs
- BidPrivateBase.cs
- SecurityUtils.cs
- WorkflowWebService.cs
- StackOverflowException.cs
- ResourcePool.cs
- SelectedPathEditor.cs
- IncomingWebResponseContext.cs
- HttpHandler.cs
- XmlCompatibilityReader.cs
- VirtualPath.cs
- CustomSignedXml.cs
- GlobalProxySelection.cs
- VisualStyleInformation.cs
- InstanceContextMode.cs
- RelatedPropertyManager.cs
- HttpListenerElement.cs
- DbParameterCollection.cs
- MembershipValidatePasswordEventArgs.cs
- TextElement.cs
- IntPtr.cs
- FunctionImportElement.cs
- ParameterModifier.cs
- VBIdentifierName.cs
- TypeResolver.cs
- PersistenceException.cs
- ProtocolViolationException.cs
- SizeIndependentAnimationStorage.cs
- AutoScrollExpandMessageFilter.cs
- ReliabilityContractAttribute.cs
- ParserStreamGeometryContext.cs
- ToolBarPanel.cs
- NamespaceList.cs
- RNGCryptoServiceProvider.cs
- TypeConverterMarkupExtension.cs
- ConnectionInterfaceCollection.cs
- CodeDirectiveCollection.cs
- DocumentsTrace.cs
- WsdlBuildProvider.cs
- ThemeDirectoryCompiler.cs
- XmlBufferReader.cs
- CodeGenerator.cs
- TagNameToTypeMapper.cs
- FixedSOMLineCollection.cs
- SequenceQuery.cs
- BinaryWriter.cs
- bidPrivateBase.cs
- ConnectionManagementSection.cs
- AssociatedControlConverter.cs
- XPathBinder.cs
- ConstructorNeedsTagAttribute.cs
- StringSorter.cs
- XsdValidatingReader.cs
- QuaternionAnimationBase.cs
- CompilerParameters.cs
- VirtualPath.cs
- ServiceModelConfigurationSectionGroup.cs