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 for the specified stream.
/// 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);
}
/// 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..
/// should be a byte array.
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.
//----------------------------------------------------------------------
//
// 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 for the specified stream.
/// 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);
}
/// 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..
/// should be a byte array.
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReceiveMessageRecord.cs
- IdentityReference.cs
- RegistryPermission.cs
- HttpHeaderCollection.cs
- Point3DIndependentAnimationStorage.cs
- BaseCodeDomTreeGenerator.cs
- _AuthenticationState.cs
- LinkLabelLinkClickedEvent.cs
- ErrorsHelper.cs
- PixelFormat.cs
- UriTemplateDispatchFormatter.cs
- CrossContextChannel.cs
- ContextActivityUtils.cs
- WebPartMinimizeVerb.cs
- FullTrustAssembliesSection.cs
- GatewayDefinition.cs
- XsltArgumentList.cs
- GPPOINT.cs
- ProviderConnectionPointCollection.cs
- TargetConverter.cs
- XamlToRtfWriter.cs
- WebPartEditorApplyVerb.cs
- DataRecord.cs
- FastPropertyAccessor.cs
- NotifyCollectionChangedEventArgs.cs
- CLSCompliantAttribute.cs
- CodeExpressionStatement.cs
- BuildProvider.cs
- XPathScanner.cs
- SqlClientWrapperSmiStreamChars.cs
- MimeWriter.cs
- ListViewItemSelectionChangedEvent.cs
- LayoutEvent.cs
- SortKey.cs
- HtmlShim.cs
- SchemaNames.cs
- DefaultMemberAttribute.cs
- FileUpload.cs
- SimpleType.cs
- ModifierKeysConverter.cs
- DataViewManagerListItemTypeDescriptor.cs
- CallbackException.cs
- CreateInstanceBinder.cs
- GridSplitter.cs
- CodeGen.cs
- NameValuePair.cs
- securitycriticaldataformultiplegetandset.cs
- ImageCodecInfoPrivate.cs
- WindowsIPAddress.cs
- MatrixIndependentAnimationStorage.cs
- SweepDirectionValidation.cs
- WindowsTitleBar.cs
- ToolBar.cs
- TokenCreationParameter.cs
- AsyncOperation.cs
- TracedNativeMethods.cs
- HtmlElementErrorEventArgs.cs
- XmlElementAttribute.cs
- ProvideValueServiceProvider.cs
- TypeInfo.cs
- TextServicesPropertyRanges.cs
- CacheChildrenQuery.cs
- DecimalStorage.cs
- TreeChangeInfo.cs
- HttpCachePolicyElement.cs
- RuntimeConfigurationRecord.cs
- ObjectDataSourceView.cs
- HitTestDrawingContextWalker.cs
- GeometryConverter.cs
- QuaternionKeyFrameCollection.cs
- DataDocumentXPathNavigator.cs
- XpsColorContext.cs
- ProcessInfo.cs
- ObjectResult.cs
- WFItemsToSpacerVisibility.cs
- ObservableCollection.cs
- BreakRecordTable.cs
- Lookup.cs
- GridViewRowEventArgs.cs
- ExcludeFromCodeCoverageAttribute.cs
- MeasurementDCInfo.cs
- SkipStoryboardToFill.cs
- RegexBoyerMoore.cs
- DecimalConstantAttribute.cs
- ConfigurationSectionCollection.cs
- RepeatBehaviorConverter.cs
- SafeArrayTypeMismatchException.cs
- RequestResponse.cs
- KoreanCalendar.cs
- SharedUtils.cs
- basevalidator.cs
- DataKeyArray.cs
- DbConnectionInternal.cs
- DataGridViewCellLinkedList.cs
- TagPrefixCollection.cs
- ItemCheckEvent.cs
- WebPartTransformerAttribute.cs
- StopRoutingHandler.cs
- ToolStripControlHost.cs
- UnsafeNativeMethods.cs