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
- InstalledFontCollection.cs
- ValidationErrorEventArgs.cs
- AudioSignalProblemOccurredEventArgs.cs
- ExpressionBuilderContext.cs
- nulltextnavigator.cs
- Item.cs
- AudioDeviceOut.cs
- ChildTable.cs
- MessageQueue.cs
- BadImageFormatException.cs
- DbMetaDataColumnNames.cs
- EdmProperty.cs
- DateTimePicker.cs
- SecurityCookieModeValidator.cs
- Debug.cs
- SafeRightsManagementHandle.cs
- HtmlElementErrorEventArgs.cs
- EnumCodeDomSerializer.cs
- StylusDevice.cs
- Transform3DCollection.cs
- SystemResourceHost.cs
- NamespaceQuery.cs
- Size3DValueSerializer.cs
- TextElement.cs
- PermissionAttributes.cs
- SoapTypeAttribute.cs
- AvtEvent.cs
- TextParaClient.cs
- MouseGestureConverter.cs
- RSAPKCS1SignatureDeformatter.cs
- wgx_commands.cs
- PrimitiveRenderer.cs
- SymmetricKeyWrap.cs
- ToolBarPanel.cs
- AuthenticatingEventArgs.cs
- WebSysDefaultValueAttribute.cs
- querybuilder.cs
- OracleRowUpdatedEventArgs.cs
- TimelineClockCollection.cs
- DelayLoadType.cs
- ColorTransformHelper.cs
- Size3DConverter.cs
- BorderGapMaskConverter.cs
- ActionFrame.cs
- OpCodes.cs
- CodeAssignStatement.cs
- ConsoleCancelEventArgs.cs
- AssemblySettingAttributes.cs
- GraphicsPathIterator.cs
- COM2ColorConverter.cs
- ParseHttpDate.cs
- DataContractFormatAttribute.cs
- DESCryptoServiceProvider.cs
- TemplatedWizardStep.cs
- WindowsFormsLinkLabel.cs
- CryptoConfig.cs
- TrackingMemoryStream.cs
- PropertyDescriptorCollection.cs
- ReadOnlyNameValueCollection.cs
- RegexInterpreter.cs
- TokenBasedSet.cs
- UpdatePanelControlTrigger.cs
- DiscoveryInnerClientAdhoc11.cs
- ReadOnlyDataSourceView.cs
- DataTemplate.cs
- OrderedEnumerableRowCollection.cs
- SerializationInfoEnumerator.cs
- PersistenceProviderFactory.cs
- RelationshipEndCollection.cs
- Form.cs
- FamilyMap.cs
- DuplicateContext.cs
- _HeaderInfoTable.cs
- OperationBehaviorAttribute.cs
- ArraySubsetEnumerator.cs
- TransportReplyChannelAcceptor.cs
- SelectedDatesCollection.cs
- SystemDiagnosticsSection.cs
- SqlParameterizer.cs
- DataGridAutomationPeer.cs
- IconConverter.cs
- BooleanKeyFrameCollection.cs
- DbConnectionPoolGroupProviderInfo.cs
- NetDataContractSerializer.cs
- FontEmbeddingManager.cs
- PointCollection.cs
- CallbackHandler.cs
- TextModifier.cs
- UnsafeNativeMethods.cs
- XamlSerializer.cs
- DesignParameter.cs
- IResourceProvider.cs
- EndPoint.cs
- ConditionalWeakTable.cs
- PenLineCapValidation.cs
- SqlRewriteScalarSubqueries.cs
- Triplet.cs
- RSACryptoServiceProvider.cs
- GB18030Encoding.cs
- _RequestCacheProtocol.cs