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
- CryptoProvider.cs
- InsufficientMemoryException.cs
- TransformerTypeCollection.cs
- TimeoutValidationAttribute.cs
- HtmlControlPersistable.cs
- Clause.cs
- SqlTriggerContext.cs
- DbProviderConfigurationHandler.cs
- Translator.cs
- ContextInformation.cs
- Set.cs
- FileReader.cs
- OdbcFactory.cs
- UnionCodeGroup.cs
- PeerResolver.cs
- Empty.cs
- UdpDiscoveryMessageFilter.cs
- ResourceDefaultValueAttribute.cs
- SerializationInfo.cs
- WeakReferenceList.cs
- TaskResultSetter.cs
- AnnotationResourceChangedEventArgs.cs
- RequestCache.cs
- NameSpaceExtractor.cs
- UrlPath.cs
- TagMapCollection.cs
- BindableAttribute.cs
- DelegateSerializationHolder.cs
- ObjectPersistData.cs
- Screen.cs
- FixedTextView.cs
- DataContractSerializerFaultFormatter.cs
- HashMembershipCondition.cs
- DataSourceControlBuilder.cs
- ComponentDispatcher.cs
- RemotingConfigParser.cs
- DataSourceProvider.cs
- GrabHandleGlyph.cs
- TextWriterTraceListener.cs
- AnimationClock.cs
- PrintPreviewControl.cs
- EventHandlersDesigner.cs
- Parsers.cs
- HuffModule.cs
- SafeWaitHandle.cs
- IERequestCache.cs
- TransactionProtocolConverter.cs
- ContourSegment.cs
- Separator.cs
- TypeSystemProvider.cs
- ProxyManager.cs
- MetafileHeaderWmf.cs
- FormCollection.cs
- ViewBox.cs
- DescendantQuery.cs
- StoreItemCollection.Loader.cs
- EdmProviderManifest.cs
- FlagsAttribute.cs
- XPathAxisIterator.cs
- SecurityKeyType.cs
- RichTextBox.cs
- MetadataPropertyCollection.cs
- WindowsGraphics.cs
- FormatConvertedBitmap.cs
- IndicCharClassifier.cs
- BinaryReader.cs
- ProfileProvider.cs
- StandardOleMarshalObject.cs
- EngineSiteSapi.cs
- PathSegmentCollection.cs
- StoreAnnotationsMap.cs
- EventLogPermissionEntryCollection.cs
- CoreChannel.cs
- TdsValueSetter.cs
- WsdlParser.cs
- NetPeerTcpBindingElement.cs
- HTTPNotFoundHandler.cs
- ExpandCollapseProviderWrapper.cs
- NavigationPropertyEmitter.cs
- RadioButton.cs
- EmptyQuery.cs
- AssemblyHash.cs
- OleDbMetaDataFactory.cs
- DashStyles.cs
- RegexReplacement.cs
- SharedStatics.cs
- _ListenerAsyncResult.cs
- RowToParametersTransformer.cs
- BulletedListEventArgs.cs
- DataGridViewRowPrePaintEventArgs.cs
- AnnouncementInnerClientCD1.cs
- PrivilegedConfigurationManager.cs
- EpmContentSerializer.cs
- CodeParameterDeclarationExpression.cs
- ToolStripSystemRenderer.cs
- ComponentEditorPage.cs
- TableItemPattern.cs
- DataRecord.cs
- ArglessEventHandlerProxy.cs
- unitconverter.cs