Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / TextSerializer.cs / 1305376 / 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
- InputProcessorProfiles.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ZipIOExtraFieldPaddingElement.cs
- ChannelManagerService.cs
- HotSpotCollection.cs
- DeflateEmulationStream.cs
- ColumnReorderedEventArgs.cs
- PcmConverter.cs
- Condition.cs
- RootContext.cs
- GenericUriParser.cs
- PageMediaSize.cs
- ListViewUpdatedEventArgs.cs
- NullableDoubleMinMaxAggregationOperator.cs
- Vector3dCollection.cs
- MatrixValueSerializer.cs
- Root.cs
- TrustSection.cs
- SafeProcessHandle.cs
- PropertyBuilder.cs
- WebPartExportVerb.cs
- DetailsViewRow.cs
- ServiceOperationUIEditor.cs
- TypeBuilder.cs
- TripleDESCryptoServiceProvider.cs
- FakeModelItemImpl.cs
- EdmComplexPropertyAttribute.cs
- _AutoWebProxyScriptEngine.cs
- FileStream.cs
- NativeMethods.cs
- AuthenticationServiceManager.cs
- TextPointerBase.cs
- TextServicesPropertyRanges.cs
- ResourceAttributes.cs
- ISFTagAndGuidCache.cs
- ProfileService.cs
- metrodevice.cs
- CookieParameter.cs
- NetworkStream.cs
- Button.cs
- LocationEnvironment.cs
- RewritingSimplifier.cs
- DataGridViewRowCancelEventArgs.cs
- XmlSchemaChoice.cs
- UnsafeNativeMethods.cs
- ActiveXSite.cs
- InternalConfirm.cs
- SaveFileDialog.cs
- DataPagerFieldCommandEventArgs.cs
- WebPartEventArgs.cs
- CustomLineCap.cs
- ServiceEndpointAssociationProvider.cs
- ToolStripLocationCancelEventArgs.cs
- WarningException.cs
- ValueType.cs
- ArcSegment.cs
- BinaryCommonClasses.cs
- InfoCardProofToken.cs
- PathFigureCollectionValueSerializer.cs
- Delegate.cs
- XmlNavigatorFilter.cs
- Point3DAnimationUsingKeyFrames.cs
- AnimationClockResource.cs
- ToolStripDropDownItem.cs
- ExternalFile.cs
- FileChangesMonitor.cs
- ColumnCollection.cs
- ColorInterpolationModeValidation.cs
- DataGridRelationshipRow.cs
- BindToObject.cs
- CheckableControlBaseAdapter.cs
- PolygonHotSpot.cs
- ParamArrayAttribute.cs
- TextDecoration.cs
- DropShadowBitmapEffect.cs
- UIElement3DAutomationPeer.cs
- EntitySqlQueryCacheEntry.cs
- BitmapEffectInput.cs
- PropertyTabChangedEvent.cs
- TableLayoutSettings.cs
- LogLogRecordEnumerator.cs
- QueueProcessor.cs
- OleDbCommandBuilder.cs
- CdpEqualityComparer.cs
- NamedPermissionSet.cs
- StorageConditionPropertyMapping.cs
- ComponentChangingEvent.cs
- XmlWriter.cs
- ImpersonateTokenRef.cs
- _ListenerRequestStream.cs
- ScriptBehaviorDescriptor.cs
- UpdateTranslator.cs
- BigIntegerStorage.cs
- Expander.cs
- OleDbCommandBuilder.cs
- TextPointerBase.cs
- PermissionListSet.cs
- ObjectDataSource.cs
- AspCompat.cs
- GlyphingCache.cs