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
- Nullable.cs
- ApplicationContext.cs
- HttpAsyncResult.cs
- PinnedBufferMemoryStream.cs
- AppDomainAttributes.cs
- XPathSingletonIterator.cs
- Msec.cs
- TreeNodeConverter.cs
- SpeechRecognizer.cs
- ChildrenQuery.cs
- AppLevelCompilationSectionCache.cs
- FormsAuthenticationCredentials.cs
- DivideByZeroException.cs
- HtmlTableRow.cs
- DrawingContextDrawingContextWalker.cs
- ScaleTransform.cs
- BitmapFrame.cs
- SliderAutomationPeer.cs
- XamlGridLengthSerializer.cs
- NameScope.cs
- ScriptReferenceBase.cs
- SqlTypeSystemProvider.cs
- ControlPaint.cs
- SafeBitVector32.cs
- XsltLoader.cs
- Label.cs
- RC2CryptoServiceProvider.cs
- Regex.cs
- FontWeight.cs
- securestring.cs
- ProxyElement.cs
- RSAPKCS1KeyExchangeFormatter.cs
- StringExpressionSet.cs
- XPathScanner.cs
- Attributes.cs
- HttpApplication.cs
- WindowsPen.cs
- Constraint.cs
- RawUIStateInputReport.cs
- ApplicationServiceHelper.cs
- FontCacheUtil.cs
- PropertyPathWorker.cs
- FontFamily.cs
- QilBinary.cs
- WebControlAdapter.cs
- JulianCalendar.cs
- XmlSchemaChoice.cs
- Cursor.cs
- CqlIdentifiers.cs
- UnauthorizedAccessException.cs
- GeometryHitTestParameters.cs
- XmlAttributeProperties.cs
- PropertyOverridesTypeEditor.cs
- DtrList.cs
- DesignerForm.cs
- VirtualDirectoryMapping.cs
- WebPartUtil.cs
- LocatorPartList.cs
- DbProviderManifest.cs
- Padding.cs
- FixedTextContainer.cs
- TemplatedMailWebEventProvider.cs
- CapabilitiesState.cs
- ZoomingMessageFilter.cs
- ToolStripSettings.cs
- FreezableOperations.cs
- SchemaExporter.cs
- UrlMapping.cs
- SafeLocalMemHandle.cs
- TemplateControlCodeDomTreeGenerator.cs
- InternalsVisibleToAttribute.cs
- CustomTypeDescriptor.cs
- Context.cs
- ListBase.cs
- WSSecurityTokenSerializer.cs
- EmbeddedMailObject.cs
- WebConfigurationHost.cs
- SystemWebSectionGroup.cs
- OutputCache.cs
- EncoderNLS.cs
- DataBoundControlHelper.cs
- PasswordTextContainer.cs
- XhtmlStyleClass.cs
- DocumentApplicationDocumentViewer.cs
- PersistencePipeline.cs
- ControlBuilder.cs
- SqlConnectionManager.cs
- HtmlLink.cs
- StateMachine.cs
- LassoHelper.cs
- ProfileInfo.cs
- WebPartZoneBase.cs
- CapabilitiesUse.cs
- ValidationService.cs
- AccessibleObject.cs
- MetadataArtifactLoaderResource.cs
- DashStyle.cs
- SettingsBase.cs
- smtppermission.cs
- LineGeometry.cs