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
- CellRelation.cs
- Socket.cs
- CodeMemberField.cs
- ReservationCollection.cs
- PlanCompiler.cs
- X509CertificateStore.cs
- PolyBezierSegmentFigureLogic.cs
- BasicExpressionVisitor.cs
- DeclaredTypeValidator.cs
- ProviderSettings.cs
- DesignerAdapterAttribute.cs
- UnsafeNativeMethodsMilCoreApi.cs
- IsolatedStorageSecurityState.cs
- DetailsViewUpdateEventArgs.cs
- DescriptionAttribute.cs
- WebResourceAttribute.cs
- AnnotationHighlightLayer.cs
- ReflectionTypeLoadException.cs
- UriParserTemplates.cs
- EventArgs.cs
- AliasExpr.cs
- InputProcessorProfiles.cs
- URLMembershipCondition.cs
- QuaternionRotation3D.cs
- ResourceContainer.cs
- CoreSwitches.cs
- ProxyHwnd.cs
- ComplexBindingPropertiesAttribute.cs
- PerformanceCounterLib.cs
- xamlnodes.cs
- SecurityTokenParameters.cs
- EntityDataSourceContextDisposingEventArgs.cs
- ComponentResourceKey.cs
- VisualBasicImportReference.cs
- MenuItemStyleCollection.cs
- EncoderBestFitFallback.cs
- VoiceSynthesis.cs
- DateTimeParse.cs
- UseManagedPresentationBindingElement.cs
- QuaternionValueSerializer.cs
- EventLogPermissionEntry.cs
- ToolStripRenderEventArgs.cs
- TreeWalker.cs
- SetterBaseCollection.cs
- _AuthenticationState.cs
- IPGlobalProperties.cs
- ErrorCodes.cs
- DataShape.cs
- ComponentChangingEvent.cs
- TreeBuilder.cs
- ProfilePropertySettingsCollection.cs
- SqlDataSourceParameterParser.cs
- XMLSchema.cs
- XamlStyleSerializer.cs
- ToolbarAUtomationPeer.cs
- XmlSchemaComplexContentRestriction.cs
- DataControlCommands.cs
- NameNode.cs
- ListViewItemMouseHoverEvent.cs
- DataGridViewColumnCollection.cs
- EmbossBitmapEffect.cs
- EntityDataSourceValidationException.cs
- CroppedBitmap.cs
- RecordConverter.cs
- StateMachineSubscription.cs
- PopupRootAutomationPeer.cs
- InputElement.cs
- StrongNameMembershipCondition.cs
- BaseDataListDesigner.cs
- SmiRecordBuffer.cs
- TextSearch.cs
- SerializerWriterEventHandlers.cs
- tooltip.cs
- ServiceDescriptionContext.cs
- XmlSchemaExporter.cs
- EventRoute.cs
- HtmlToClrEventProxy.cs
- DateTimeConstantAttribute.cs
- SignedXmlDebugLog.cs
- DoubleAnimationClockResource.cs
- SoapCommonClasses.cs
- BindingMAnagerBase.cs
- DataGridViewCell.cs
- SamlAudienceRestrictionCondition.cs
- ListCollectionView.cs
- CapabilitiesState.cs
- CryptoKeySecurity.cs
- RectAnimation.cs
- SecurityUtils.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- BrowserCapabilitiesCodeGenerator.cs
- SelectorAutomationPeer.cs
- OrderedEnumerableRowCollection.cs
- ListViewDesigner.cs
- ThicknessConverter.cs
- PropertyExpression.cs
- PkcsUtils.cs
- ExcludePathInfo.cs
- HttpRequestWrapper.cs
- DeviceSpecificDesigner.cs