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
- WindowsGraphics.cs
- ApplicationFileCodeDomTreeGenerator.cs
- DbParameterCollectionHelper.cs
- ConnectionPoolManager.cs
- ContainerControlDesigner.cs
- PageThemeBuildProvider.cs
- DataGridViewDataConnection.cs
- XamlTemplateSerializer.cs
- TableRow.cs
- StringStorage.cs
- EventOpcode.cs
- _SecureChannel.cs
- ColumnPropertiesGroup.cs
- WebPartAddingEventArgs.cs
- PolyBezierSegmentFigureLogic.cs
- AuthenticationService.cs
- XdrBuilder.cs
- WindowsFormsSynchronizationContext.cs
- safelinkcollection.cs
- BulletedList.cs
- StickyNote.cs
- ExpressionPrinter.cs
- SspiHelper.cs
- VisualBasicSettings.cs
- securestring.cs
- VerificationAttribute.cs
- SupportsEventValidationAttribute.cs
- MD5.cs
- RuleInfoComparer.cs
- SimpleWorkerRequest.cs
- FixUp.cs
- UnmanagedMemoryStreamWrapper.cs
- DataGridViewSelectedRowCollection.cs
- ToolStripStatusLabel.cs
- SqlTypeConverter.cs
- FacetDescription.cs
- RangeValidator.cs
- TargetControlTypeCache.cs
- CompoundFileReference.cs
- WebServiceClientProxyGenerator.cs
- figurelength.cs
- VerticalAlignConverter.cs
- DelegateCompletionCallbackWrapper.cs
- LateBoundBitmapDecoder.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ContextMenuAutomationPeer.cs
- SubpageParagraph.cs
- Decorator.cs
- SimpleApplicationHost.cs
- WmlCommandAdapter.cs
- PersonalizationProviderCollection.cs
- CompoundFileIOPermission.cs
- SafeEventLogReadHandle.cs
- BitmapDecoder.cs
- Pkcs9Attribute.cs
- WebControlAdapter.cs
- SamlSecurityTokenAuthenticator.cs
- SecurityPermission.cs
- CorrelationResolver.cs
- CodeIndexerExpression.cs
- CornerRadius.cs
- Point4DConverter.cs
- TriggerBase.cs
- AggregatePushdown.cs
- XamlVector3DCollectionSerializer.cs
- SerializableAuthorizationContext.cs
- EventDescriptor.cs
- DataServiceQueryOfT.cs
- DataBoundControl.cs
- WmpBitmapEncoder.cs
- CodeAttachEventStatement.cs
- DefaultPropertiesToSend.cs
- Control.cs
- HtmlInputPassword.cs
- TextParentUndoUnit.cs
- TextTreeNode.cs
- IsolatedStorageFilePermission.cs
- Activity.cs
- ReachPrintTicketSerializerAsync.cs
- BinaryCommonClasses.cs
- RoutedUICommand.cs
- TypeSchema.cs
- WriteableOnDemandPackagePart.cs
- M3DUtil.cs
- IndentTextWriter.cs
- PartialCachingControl.cs
- BaseTemplatedMobileComponentEditor.cs
- MD5CryptoServiceProvider.cs
- RouteParameter.cs
- ApplicationActivator.cs
- BitmapEffectDrawing.cs
- ApplicationId.cs
- SimpleType.cs
- UdpDiscoveryEndpointProvider.cs
- EnumValidator.cs
- CultureInfoConverter.cs
- METAHEADER.cs
- MailSettingsSection.cs
- EventListener.cs
- AstNode.cs