Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- TextEditorCopyPaste.cs
- AsyncOperationManager.cs
- DetailsView.cs
- StorageConditionPropertyMapping.cs
- Query.cs
- SQLDoubleStorage.cs
- CookieParameter.cs
- VersionPair.cs
- CodeGotoStatement.cs
- TableDetailsCollection.cs
- DeflateStream.cs
- ThemeDirectoryCompiler.cs
- CounterSample.cs
- CatalogZone.cs
- LinqDataSourceHelper.cs
- XmlProcessingInstruction.cs
- MaterialGroup.cs
- SqlBooleanizer.cs
- DropShadowEffect.cs
- SaveFileDialogDesigner.cs
- TreeNodeClickEventArgs.cs
- ItemList.cs
- SmtpAuthenticationManager.cs
- WindowsFormsHostAutomationPeer.cs
- ProfileEventArgs.cs
- SchemaInfo.cs
- GenericQueueSurrogate.cs
- WebPartTransformerAttribute.cs
- SerializationUtility.cs
- SoapHeaderException.cs
- MessageBox.cs
- CannotUnloadAppDomainException.cs
- BaseAddressPrefixFilterElement.cs
- SelectionRange.cs
- DefaultWorkflowSchedulerService.cs
- CodeSubDirectory.cs
- Graphics.cs
- UInt64.cs
- SystemPens.cs
- SelectedGridItemChangedEvent.cs
- ACL.cs
- CmsUtils.cs
- GACMembershipCondition.cs
- TcpChannelFactory.cs
- DocumentXPathNavigator.cs
- ToolTip.cs
- MessageQueueAccessControlEntry.cs
- Style.cs
- MobileFormsAuthentication.cs
- DataGridViewIntLinkedList.cs
- SystemUnicastIPAddressInformation.cs
- EntityType.cs
- SqlCacheDependencyDatabase.cs
- ToolboxDataAttribute.cs
- ValidationPropertyAttribute.cs
- IteratorFilter.cs
- PersistNameAttribute.cs
- BufferedGraphicsManager.cs
- SafeSecurityHandles.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- FormClosedEvent.cs
- FormViewUpdatedEventArgs.cs
- GenericsNotImplementedException.cs
- MembershipSection.cs
- InkCanvasAutomationPeer.cs
- ImageAutomationPeer.cs
- SplitContainer.cs
- StateBag.cs
- WpfPayload.cs
- SecurityContext.cs
- DataGridCellItemAutomationPeer.cs
- MemoryRecordBuffer.cs
- sqlpipe.cs
- AutomationElementCollection.cs
- TreeNodeMouseHoverEvent.cs
- DiscoveryClientReferences.cs
- SqlCacheDependencyDatabaseCollection.cs
- CodeEventReferenceExpression.cs
- ObjectTypeMapping.cs
- RoutingExtensionElement.cs
- HttpCacheVary.cs
- DefinitionBase.cs
- TdsParserStateObject.cs
- nulltextnavigator.cs
- DelegatingTypeDescriptionProvider.cs
- EntitySqlQueryState.cs
- WebFormsRootDesigner.cs
- WinEventWrap.cs
- LinqDataSourceSelectEventArgs.cs
- QuotedPrintableStream.cs
- CryptoApi.cs
- TextTrailingWordEllipsis.cs
- DesigntimeLicenseContextSerializer.cs
- PkcsUtils.cs
- BufferedGraphicsContext.cs
- EmbossBitmapEffect.cs
- XmlDomTextWriter.cs
- HtmlGenericControl.cs
- StylusPointPropertyInfoDefaults.cs
- XmlNotation.cs