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
- SerializerDescriptor.cs
- ConsumerConnectionPointCollection.cs
- ProfilePropertyNameValidator.cs
- InterleavedZipPartStream.cs
- ListItemsCollectionEditor.cs
- ActiveDocumentEvent.cs
- QilXmlWriter.cs
- Rotation3DAnimationBase.cs
- AssemblyBuilder.cs
- Tokenizer.cs
- GroupQuery.cs
- EntityCollection.cs
- TextReader.cs
- CompositeActivityValidator.cs
- SecureUICommand.cs
- Range.cs
- DateTimeFormatInfo.cs
- MetaModel.cs
- PluralizationService.cs
- FixedSOMElement.cs
- PermissionSetEnumerator.cs
- ListViewItemEventArgs.cs
- ResolveNameEventArgs.cs
- WindowsSecurityToken.cs
- HTMLTagNameToTypeMapper.cs
- UnsafePeerToPeerMethods.cs
- DivideByZeroException.cs
- RowBinding.cs
- EvidenceBase.cs
- SqlUtils.cs
- InvalidDataException.cs
- COM2Properties.cs
- MissingMethodException.cs
- XhtmlBasicControlAdapter.cs
- SecurityVersion.cs
- LoginStatusDesigner.cs
- HistoryEventArgs.cs
- EncoderNLS.cs
- UriSectionReader.cs
- MailMessage.cs
- HttpRuntime.cs
- GreenMethods.cs
- IndexedEnumerable.cs
- KeyTimeConverter.cs
- DataSourceProvider.cs
- ToolStripItem.cs
- WebConfigurationFileMap.cs
- SafeCryptContextHandle.cs
- TextPenaltyModule.cs
- CommunicationObject.cs
- Constraint.cs
- CreateRefExpr.cs
- ViewStateException.cs
- BooleanFunctions.cs
- DataControlFieldTypeEditor.cs
- WorkflowDesignerMessageFilter.cs
- Assign.cs
- ToolboxBitmapAttribute.cs
- RootContext.cs
- dataobject.cs
- HtmlInputFile.cs
- QilDataSource.cs
- StateFinalizationDesigner.cs
- CompatibleIComparer.cs
- ButtonRenderer.cs
- ChannelFactory.cs
- SerializerDescriptor.cs
- EpmContentSerializerBase.cs
- MetadataExporter.cs
- NetworkInformationPermission.cs
- FileCodeGroup.cs
- ListBindingConverter.cs
- TraceInternal.cs
- Attributes.cs
- AssemblyBuilderData.cs
- BitmapFrame.cs
- SafeFindHandle.cs
- AtomicFile.cs
- Message.cs
- SQLBinaryStorage.cs
- InputLanguageProfileNotifySink.cs
- XmlNotation.cs
- TranslateTransform3D.cs
- ExtendedPropertyInfo.cs
- Accessible.cs
- SmtpClient.cs
- RIPEMD160.cs
- SizeAnimationClockResource.cs
- SEHException.cs
- SchemaCollectionCompiler.cs
- FuncCompletionCallbackWrapper.cs
- InstalledFontCollection.cs
- PhysicalFontFamily.cs
- CorrelationExtension.cs
- DESCryptoServiceProvider.cs
- SelfIssuedAuthAsymmetricKey.cs
- SkewTransform.cs
- PointConverter.cs
- EnumBuilder.cs
- Sql8ExpressionRewriter.cs