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
- GlyphCache.cs
- FixedElement.cs
- ReadOnlyDictionary.cs
- DataExpression.cs
- NodeLabelEditEvent.cs
- QilUnary.cs
- XmlRawWriter.cs
- ASCIIEncoding.cs
- MetabaseSettings.cs
- DeadCharTextComposition.cs
- Message.cs
- PropertyMappingExceptionEventArgs.cs
- SessionStateModule.cs
- PageThemeParser.cs
- QueryContinueDragEventArgs.cs
- DrawingContext.cs
- DrawingDrawingContext.cs
- InstanceLockQueryResult.cs
- ToolStripControlHost.cs
- RelativeSource.cs
- PropertyCollection.cs
- HttpProfileBase.cs
- WinEventWrap.cs
- TableDetailsCollection.cs
- SignedPkcs7.cs
- HtmlObjectListAdapter.cs
- xml.cs
- XmlNamespaceManager.cs
- CatalogPart.cs
- NavigationPropertyEmitter.cs
- ZipIOExtraFieldZip64Element.cs
- HandlerBase.cs
- EventPrivateKey.cs
- UnconditionalPolicy.cs
- SelectionPattern.cs
- WebPartConnection.cs
- PageEventArgs.cs
- ConversionContext.cs
- IgnoreDataMemberAttribute.cs
- RC2.cs
- SQLMoney.cs
- SQLInt64.cs
- SetterBaseCollection.cs
- EditBehavior.cs
- RichTextBoxConstants.cs
- PartitionerQueryOperator.cs
- BitmapFrame.cs
- WebReferencesBuildProvider.cs
- Options.cs
- HttpRawResponse.cs
- CommandID.cs
- WebPartActionVerb.cs
- WebPart.cs
- HtmlFormParameterReader.cs
- MappedMetaModel.cs
- CodeSubDirectoriesCollection.cs
- TypeSemantics.cs
- DataObjectEventArgs.cs
- PeerNameRecord.cs
- XmlDocument.cs
- ExpressionPrefixAttribute.cs
- Graph.cs
- EncoderFallback.cs
- Vector3DCollectionConverter.cs
- WebPartZone.cs
- UIElement.cs
- NativeMethods.cs
- FileChangesMonitor.cs
- SqlMultiplexer.cs
- VSWCFServiceContractGenerator.cs
- InputEventArgs.cs
- DBAsyncResult.cs
- WindowsServiceCredential.cs
- TcpServerChannel.cs
- XmlDocumentSerializer.cs
- DynamicControl.cs
- DirectoryObjectSecurity.cs
- SafeNativeMethodsCLR.cs
- ReferencedType.cs
- ToolTip.cs
- StringUtil.cs
- XPathScanner.cs
- StringUtil.cs
- WebPartDisplayModeCancelEventArgs.cs
- RuleSettingsCollection.cs
- XamlSerializer.cs
- ContractType.cs
- SafeNativeMethods.cs
- Cursor.cs
- SafeLocalMemHandle.cs
- BufferedWebEventProvider.cs
- BufferedResponseStream.cs
- QueryCacheEntry.cs
- BitmapData.cs
- OrderedDictionary.cs
- Repeater.cs
- WebPartDescription.cs
- dataSvcMapFileLoader.cs
- ToolBarButtonClickEvent.cs
- BitmapEffect.cs