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 / BinarySerializer.cs / 1 / BinarySerializer.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a serializer for binary content.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Serializers
{
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
/// Provides support for serializing responses in binary format.
///
/// The file histroy should show a BinaryExceptionTextWriter which is no longer used.
///
internal struct BinarySerializer : IExceptionWriter
{
/// Stream to which output is sent.
private readonly Stream outputStream;
/// Initializes a new for the specified stream.
/// Stream to which output should be sent.
internal BinarySerializer(Stream output)
{
Debug.Assert(output != null, "output != null");
this.outputStream = output;
}
/// Serializes exception information.
/// Description of exception to serialize.
public void WriteException(HandleExceptionArgs args)
{
Debug.Assert(args != null, "args != null");
XmlWriter xmlWriter = XmlWriter.Create(this.outputStream);
ErrorHandler.SerializeXmlError(args, xmlWriter);
xmlWriter.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");
// The metadata layer should only accept byte arrays as binary-serialized values.
byte[] bytes;
if (content is byte[])
{
bytes = (byte[])content;
}
else
{
bytes = (byte[])((System.Data.Linq.Binary)content).ToArray();
}
this.outputStream.Write(bytes, 0, bytes.Length);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a serializer for binary content.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Serializers
{
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
/// Provides support for serializing responses in binary format.
///
/// The file histroy should show a BinaryExceptionTextWriter which is no longer used.
///
internal struct BinarySerializer : IExceptionWriter
{
/// Stream to which output is sent.
private readonly Stream outputStream;
/// Initializes a new for the specified stream.
/// Stream to which output should be sent.
internal BinarySerializer(Stream output)
{
Debug.Assert(output != null, "output != null");
this.outputStream = output;
}
/// Serializes exception information.
/// Description of exception to serialize.
public void WriteException(HandleExceptionArgs args)
{
Debug.Assert(args != null, "args != null");
XmlWriter xmlWriter = XmlWriter.Create(this.outputStream);
ErrorHandler.SerializeXmlError(args, xmlWriter);
xmlWriter.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");
// The metadata layer should only accept byte arrays as binary-serialized values.
byte[] bytes;
if (content is byte[])
{
bytes = (byte[])content;
}
else
{
bytes = (byte[])((System.Data.Linq.Binary)content).ToArray();
}
this.outputStream.Write(bytes, 0, bytes.Length);
}
}
}
// 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
- XmlSchemaParticle.cs
- BuildResult.cs
- TrustSection.cs
- InternalResources.cs
- ObjectDataSourceMethodEventArgs.cs
- PropertyGridDesigner.cs
- SystemWebSectionGroup.cs
- TreeNodeClickEventArgs.cs
- XmlSchemaDocumentation.cs
- UniqueID.cs
- JournalEntryStack.cs
- ObfuscateAssemblyAttribute.cs
- PipelineComponent.cs
- OptimalBreakSession.cs
- XPathScanner.cs
- XmlILAnnotation.cs
- BindingListCollectionView.cs
- Dump.cs
- PropertyGeneratedEventArgs.cs
- TabControlEvent.cs
- UnsafeNativeMethodsTablet.cs
- NativeCppClassAttribute.cs
- TileBrush.cs
- PassportAuthentication.cs
- ManagedIStream.cs
- Size.cs
- IdentityNotMappedException.cs
- CodeDOMUtility.cs
- ActivityExecutorSurrogate.cs
- ProcessProtocolHandler.cs
- ClientConfigurationHost.cs
- WebResponse.cs
- ZipPackage.cs
- SharedPersonalizationStateInfo.cs
- UserValidatedEventArgs.cs
- XmlDictionaryReaderQuotas.cs
- PassportIdentity.cs
- WorkflowTransactionOptions.cs
- MarginsConverter.cs
- DataTableClearEvent.cs
- TreeWalker.cs
- CmsInterop.cs
- TextDecorationUnitValidation.cs
- PresentationTraceSources.cs
- TdsParserStaticMethods.cs
- ToolStripDropTargetManager.cs
- MappingItemCollection.cs
- XPathNodeIterator.cs
- SqlStatistics.cs
- HttpHandlerActionCollection.cs
- OleTxTransactionInfo.cs
- ACL.cs
- SecurityTokenProvider.cs
- RightsManagementResourceHelper.cs
- CommonRemoteMemoryBlock.cs
- BackStopAuthenticationModule.cs
- SystemFonts.cs
- WebHttpSecurityElement.cs
- PromptBuilder.cs
- MutexSecurity.cs
- VisualCollection.cs
- ValidatorCollection.cs
- TextRange.cs
- ButtonColumn.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- IArgumentProvider.cs
- DataGridViewRowCancelEventArgs.cs
- ServiceDesigner.cs
- OpenTypeLayoutCache.cs
- Select.cs
- Stylesheet.cs
- Helpers.cs
- TableLayoutPanelCellPosition.cs
- HttpCachePolicyWrapper.cs
- LocalFileSettingsProvider.cs
- ListBindingHelper.cs
- WindowsListViewScroll.cs
- OrderByBuilder.cs
- ISAPIWorkerRequest.cs
- MaterializeFromAtom.cs
- HttpCookieCollection.cs
- XmlEntityReference.cs
- LineServices.cs
- MenuBase.cs
- DataSourceControl.cs
- DataServiceConfiguration.cs
- DataGridTemplateColumn.cs
- RectangleGeometry.cs
- MetadataItemEmitter.cs
- NameValueConfigurationCollection.cs
- GroupBoxAutomationPeer.cs
- webeventbuffer.cs
- Socket.cs
- PrimitiveType.cs
- PointCollection.cs
- ObjectItemAttributeAssemblyLoader.cs
- Matrix3D.cs
- TextElementEnumerator.cs
- StreamHelper.cs
- XmlDictionaryReaderQuotas.cs