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 /// Stream to which output should be sent. internal BinarySerializer(Stream output) { Debug.Assert(output != null, "output != null"); this.outputStream = output; } ///for the specified stream. 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.. ///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. //---------------------------------------------------------------------- // should be a byte array. // 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 /// Stream to which output should be sent. internal BinarySerializer(Stream output) { Debug.Assert(output != null, "output != null"); this.outputStream = output; } ///for the specified stream. 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.. ///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. should be a byte array.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StringKeyFrameCollection.cs
- Cursors.cs
- PriorityBinding.cs
- SystemWebExtensionsSectionGroup.cs
- XmlLanguage.cs
- CharKeyFrameCollection.cs
- ValidationUtility.cs
- HostElement.cs
- StorageBasedPackageProperties.cs
- ExceptionWrapper.cs
- listitem.cs
- UtilityExtension.cs
- QilFunction.cs
- DataSourceDesigner.cs
- WebDisplayNameAttribute.cs
- MimeMapping.cs
- PropertyDescriptorComparer.cs
- InstanceKeyView.cs
- GroupJoinQueryOperator.cs
- TextProviderWrapper.cs
- SqlCacheDependency.cs
- TraceEventCache.cs
- WindowsFormsSectionHandler.cs
- XmlSchemaComplexContentExtension.cs
- LocalsItemDescription.cs
- XmlSignatureProperties.cs
- IPipelineRuntime.cs
- GlobalItem.cs
- PrintPageEvent.cs
- AdapterUtil.cs
- SecurityUniqueId.cs
- DiscoveryDocumentReference.cs
- HtmlInputButton.cs
- ACL.cs
- PasswordTextContainer.cs
- EventTrigger.cs
- CodeCommentStatementCollection.cs
- SafeFileMappingHandle.cs
- MetadataPropertyAttribute.cs
- SafeFreeMibTable.cs
- itemelement.cs
- Input.cs
- ErrorStyle.cs
- CodeParameterDeclarationExpression.cs
- PenThreadPool.cs
- PlainXmlSerializer.cs
- Style.cs
- HtmlInputPassword.cs
- CodeTypeReferenceExpression.cs
- Point.cs
- Stream.cs
- ListView.cs
- HostVisual.cs
- TdsParser.cs
- JpegBitmapDecoder.cs
- DataServiceKeyAttribute.cs
- ForwardPositionQuery.cs
- MetadataItemSerializer.cs
- XmlReader.cs
- XamlWriter.cs
- SQLInt64Storage.cs
- ProxyWebPartConnectionCollection.cs
- AsyncCompletedEventArgs.cs
- RecognitionEventArgs.cs
- ConvertEvent.cs
- TypedReference.cs
- XmlNodeComparer.cs
- BypassElementCollection.cs
- XamlTemplateSerializer.cs
- XmlComment.cs
- Set.cs
- LifetimeServices.cs
- WaitHandle.cs
- ComboBoxRenderer.cs
- InputBuffer.cs
- BufferedGraphicsManager.cs
- ConfigXmlSignificantWhitespace.cs
- DiscardableAttribute.cs
- AudioFormatConverter.cs
- CaretElement.cs
- ObjectList.cs
- PagesSection.cs
- DynamicContractTypeBuilder.cs
- ShaderEffect.cs
- FontCacheUtil.cs
- NonSerializedAttribute.cs
- TemplateColumn.cs
- XmlSiteMapProvider.cs
- TextLineResult.cs
- ErrorReporting.cs
- EdmSchemaAttribute.cs
- UnsafeNativeMethods.cs
- HttpProfileBase.cs
- VSDExceptions.cs
- CancelRequestedQuery.cs
- OpenFileDialog.cs
- NavigatorOutput.cs
- PipeStream.cs
- WebBrowserNavigatingEventHandler.cs
- MouseEventArgs.cs