Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- MenuCommand.cs
- PolyBezierSegment.cs
- SocketInformation.cs
- State.cs
- DefaultBinder.cs
- ExchangeUtilities.cs
- MimeMapping.cs
- SubMenuStyle.cs
- TextEndOfSegment.cs
- ConnectionStringEditor.cs
- RefType.cs
- VBIdentifierDesigner.xaml.cs
- RuleSettingsCollection.cs
- PreProcessor.cs
- RectValueSerializer.cs
- DataBindingCollectionEditor.cs
- WsdlInspector.cs
- safemediahandle.cs
- TableHeaderCell.cs
- ConnectionPoint.cs
- KeyValuePair.cs
- StagingAreaInputItem.cs
- CharacterHit.cs
- Vector3D.cs
- Fonts.cs
- EventMappingSettings.cs
- RoutedEventArgs.cs
- NamespaceList.cs
- ReadingWritingEntityEventArgs.cs
- MergeFailedEvent.cs
- DesignerToolboxInfo.cs
- QueryOptionExpression.cs
- DataGridColumnFloatingHeader.cs
- RestHandler.cs
- SizeLimitedCache.cs
- RadioButton.cs
- SafeThreadHandle.cs
- WinInet.cs
- ApplicationFileParser.cs
- CommandID.cs
- PointF.cs
- SpecialNameAttribute.cs
- MdiWindowListItemConverter.cs
- Graph.cs
- PageResolution.cs
- RenderData.cs
- ClassGenerator.cs
- ActivationServices.cs
- ButtonFieldBase.cs
- StaticResourceExtension.cs
- DeviceContext.cs
- DispatcherOperation.cs
- RequestDescription.cs
- SizeAnimationClockResource.cs
- XmlReaderDelegator.cs
- Int32Animation.cs
- ReadWriteSpinLock.cs
- CodeDelegateInvokeExpression.cs
- ResolveResponseInfo.cs
- XmlReflectionMember.cs
- PageCache.cs
- Types.cs
- hebrewshape.cs
- ConfigXmlWhitespace.cs
- GroupStyle.cs
- RoleGroup.cs
- XDeferredAxisSource.cs
- Directory.cs
- PowerStatus.cs
- SafeNativeMethods.cs
- FormatVersion.cs
- BulletedListEventArgs.cs
- ThousandthOfEmRealPoints.cs
- RenameRuleObjectDialog.Designer.cs
- MethodAccessException.cs
- ListItemCollection.cs
- TrustSection.cs
- SettingsPropertyNotFoundException.cs
- LogPolicy.cs
- ScopelessEnumAttribute.cs
- ByteConverter.cs
- DataSourceGroupCollection.cs
- TemplateComponentConnector.cs
- CapacityStreamGeometryContext.cs
- OletxEnlistment.cs
- CodeNamespace.cs
- SimpleBitVector32.cs
- CachedTypeface.cs
- FloaterBaseParagraph.cs
- DataGridTextBoxColumn.cs
- TreeViewItem.cs
- WindowsFormsHostAutomationPeer.cs
- ColorAnimationUsingKeyFrames.cs
- TreeViewCancelEvent.cs
- FillErrorEventArgs.cs
- metadatamappinghashervisitor.cs
- ConfigurationStrings.cs
- BevelBitmapEffect.cs
- EntityViewGenerationAttribute.cs
- SpeakInfo.cs