Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- NullableFloatMinMaxAggregationOperator.cs
- CodeArrayCreateExpression.cs
- StringConverter.cs
- XamlDesignerSerializationManager.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- MsmqInputChannelListenerBase.cs
- Polyline.cs
- BlockingCollection.cs
- Vector.cs
- VectorAnimation.cs
- DataMemberFieldConverter.cs
- InitializerFacet.cs
- HyperLinkStyle.cs
- PopupEventArgs.cs
- FontWeights.cs
- WebEvents.cs
- NamespaceInfo.cs
- Delegate.cs
- WmlPageAdapter.cs
- ModifierKeysConverter.cs
- HasCopySemanticsAttribute.cs
- DataGridDesigner.cs
- HwndSourceKeyboardInputSite.cs
- LinqDataSourceDeleteEventArgs.cs
- SineEase.cs
- XmlSchemaComplexContentRestriction.cs
- OlePropertyStructs.cs
- CanonicalXml.cs
- TypeUtils.cs
- AuthenticateEventArgs.cs
- PtsContext.cs
- ApplyHostConfigurationBehavior.cs
- CTreeGenerator.cs
- StylusEventArgs.cs
- DataGridParentRows.cs
- ToolStripTextBox.cs
- FontCacheUtil.cs
- CollectionsUtil.cs
- GroupBox.cs
- PackageProperties.cs
- SqlRemoveConstantOrderBy.cs
- StrokeNodeData.cs
- EntityDataSourceContainerNameConverter.cs
- IntSecurity.cs
- DateTimeFormatInfoScanner.cs
- RectConverter.cs
- HMACMD5.cs
- XPathMultyIterator.cs
- DBSchemaTable.cs
- ParserContext.cs
- MailWebEventProvider.cs
- DefaultDialogButtons.cs
- DataRowCollection.cs
- _NegoStream.cs
- ProgressBar.cs
- mediaclock.cs
- LoginStatusDesigner.cs
- WindowsListViewGroupSubsetLink.cs
- SapiInterop.cs
- Vector3D.cs
- BamlLocalizabilityResolver.cs
- CodeSubDirectory.cs
- FrameworkEventSource.cs
- ContainerSelectorActiveEvent.cs
- VirtualDirectoryMapping.cs
- TableRowCollection.cs
- DataGridRowHeader.cs
- CustomAttributeFormatException.cs
- XamlFilter.cs
- MD5HashHelper.cs
- ResourceReferenceKeyNotFoundException.cs
- ScaleTransform3D.cs
- AutomationPropertyInfo.cs
- UInt64.cs
- MediaPlayerState.cs
- DesignSurface.cs
- Color.cs
- DataKey.cs
- TypedLocationWrapper.cs
- PocoPropertyAccessorStrategy.cs
- PieceNameHelper.cs
- PngBitmapEncoder.cs
- ImageSourceConverter.cs
- BinaryWriter.cs
- Transform.cs
- LongValidator.cs
- ProxyGenerationError.cs
- CustomPopupPlacement.cs
- AxHost.cs
- SafeEventHandle.cs
- PageVisual.cs
- DiagnosticsConfigurationHandler.cs
- WpfXamlType.cs
- WindowsHyperlink.cs
- SecureConversationSecurityTokenParameters.cs
- URI.cs
- MobileUITypeEditor.cs
- AutoResizedEvent.cs
- DelegatedStream.cs
- HttpException.cs