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
- AsymmetricCryptoHandle.cs
- Highlights.cs
- OleDbCommandBuilder.cs
- CodeCatchClauseCollection.cs
- TypeUsageBuilder.cs
- ActivityXamlServices.cs
- Int16Animation.cs
- TableAutomationPeer.cs
- DataGridViewImageColumn.cs
- ErrorEventArgs.cs
- SystemNetworkInterface.cs
- ServiceModelPerformanceCounters.cs
- PublishLicense.cs
- ClickablePoint.cs
- Update.cs
- CompilationRelaxations.cs
- TabItemWrapperAutomationPeer.cs
- WindowsRebar.cs
- ProcessModelSection.cs
- TextDecorationCollection.cs
- SqlBulkCopyColumnMapping.cs
- XamlFxTrace.cs
- WindowInteractionStateTracker.cs
- ModelPerspective.cs
- FastEncoder.cs
- CopyCodeAction.cs
- UriTemplateDispatchFormatter.cs
- SettingsSavedEventArgs.cs
- TransactionManager.cs
- UnauthorizedWebPart.cs
- InArgument.cs
- ToolStripDropTargetManager.cs
- EntityDescriptor.cs
- FormsIdentity.cs
- PaintValueEventArgs.cs
- DeleteHelper.cs
- PropertyDescriptor.cs
- XmlSchemaComplexContentRestriction.cs
- StreamUpgradeProvider.cs
- X509SubjectKeyIdentifierClause.cs
- CodeTypeDeclaration.cs
- DataControlFieldCell.cs
- IndexerNameAttribute.cs
- NavigationHelper.cs
- _FixedSizeReader.cs
- EntityDataSourceConfigureObjectContext.cs
- BitSet.cs
- UInt16Storage.cs
- ThreadSafeList.cs
- ToolStripComboBox.cs
- CommandConverter.cs
- EventBindingService.cs
- ConcurrentBag.cs
- AsymmetricAlgorithm.cs
- KeyTime.cs
- DEREncoding.cs
- MobileCategoryAttribute.cs
- Int32Animation.cs
- LinkLabelLinkClickedEvent.cs
- PackagePartCollection.cs
- TerminateWorkflow.cs
- SimpleModelProvider.cs
- RequestQueue.cs
- WindowsHyperlink.cs
- ObjectCacheSettings.cs
- SequentialOutput.cs
- ApplicationInfo.cs
- NamespaceQuery.cs
- XPathDescendantIterator.cs
- SafeMarshalContext.cs
- CanonicalFontFamilyReference.cs
- AnonymousIdentificationModule.cs
- OptimalBreakSession.cs
- Image.cs
- ObjectMaterializedEventArgs.cs
- XamlStackWriter.cs
- InputDevice.cs
- UrlPath.cs
- MenuItemAutomationPeer.cs
- NamespaceEmitter.cs
- TextRenderingModeValidation.cs
- SafeLocalAllocation.cs
- MappedMetaModel.cs
- DataObjectMethodAttribute.cs
- RouteValueExpressionBuilder.cs
- EventLogPermissionEntry.cs
- ViewBase.cs
- PagePropertiesChangingEventArgs.cs
- XslCompiledTransform.cs
- sitestring.cs
- RootBuilder.cs
- TabPage.cs
- TableDetailsCollection.cs
- NullExtension.cs
- PassportAuthenticationEventArgs.cs
- WindowsListViewScroll.cs
- CategoryGridEntry.cs
- MeasureItemEvent.cs
- StrongNamePublicKeyBlob.cs
- XmlMembersMapping.cs