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 / 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
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- SelfIssuedTokenFactoryCredential.cs
- SecurityDocument.cs
- OleDbDataAdapter.cs
- ObjectListShowCommandsEventArgs.cs
- AliasExpr.cs
- DataContract.cs
- AuditLevel.cs
- InvokeHandlers.cs
- RouteItem.cs
- DoubleIndependentAnimationStorage.cs
- RepeatInfo.cs
- CodeDomConfigurationHandler.cs
- MessageDecoder.cs
- FilterEventArgs.cs
- SqlFormatter.cs
- DependencyPropertyDescriptor.cs
- UnsafeNativeMethods.cs
- ContentTypeSettingClientMessageFormatter.cs
- RijndaelManagedTransform.cs
- ClientSideQueueItem.cs
- LabelLiteral.cs
- SqlClientWrapperSmiStreamChars.cs
- ExpressionLink.cs
- __FastResourceComparer.cs
- PriorityRange.cs
- ConfigurationManager.cs
- ListViewDeletedEventArgs.cs
- Size.cs
- MimeParameterWriter.cs
- AsyncContentLoadedEventArgs.cs
- GAC.cs
- _NegoState.cs
- PageVisual.cs
- CheckBoxBaseAdapter.cs
- JavaScriptObjectDeserializer.cs
- XmlName.cs
- SoapTypeAttribute.cs
- HttpHandlersSection.cs
- SectionInformation.cs
- PartialList.cs
- WebBrowserContainer.cs
- DataRelationPropertyDescriptor.cs
- EventListener.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- ParseHttpDate.cs
- UIElementAutomationPeer.cs
- WebPartsPersonalization.cs
- ObjectDataSourceChooseMethodsPanel.cs
- CodeObject.cs
- HelpKeywordAttribute.cs
- SiteMapNode.cs
- XmlTextReader.cs
- PointAnimationBase.cs
- TypeDelegator.cs
- TokenDescriptor.cs
- HandlerBase.cs
- ZipFileInfo.cs
- ZipIOExtraFieldElement.cs
- Metafile.cs
- RangeContentEnumerator.cs
- ControlAdapter.cs
- PresentationSource.cs
- Util.cs
- Int64Animation.cs
- BitmapEffectOutputConnector.cs
- TcpSocketManager.cs
- AdPostCacheSubstitution.cs
- BinHexDecoder.cs
- ThousandthOfEmRealDoubles.cs
- DivideByZeroException.cs
- WindowsGraphics.cs
- SplitterEvent.cs
- RuleSetDialog.cs
- safesecurityhelperavalon.cs
- SchemaTableColumn.cs
- JulianCalendar.cs
- InstalledFontCollection.cs
- XmlObjectSerializerReadContext.cs
- DataGridViewColumnEventArgs.cs
- TreeView.cs
- TreeNodeStyle.cs
- XhtmlBasicValidatorAdapter.cs
- ComponentCollection.cs
- Tool.cs
- ClientRolePrincipal.cs
- XmlSchemaAnyAttribute.cs
- Hashtable.cs
- RadioButtonStandardAdapter.cs
- OracleInternalConnection.cs
- DataObjectMethodAttribute.cs
- ParseNumbers.cs
- BinaryNode.cs
- UserCancellationException.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- ColorAnimationBase.cs
- FileBasedResourceGroveler.cs
- DSASignatureFormatter.cs
- MessageQueueAccessControlEntry.cs
- ValidatorCollection.cs