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
- AsymmetricCryptoHandle.cs
- Splitter.cs
- NamedElement.cs
- WindowsPrincipal.cs
- FillRuleValidation.cs
- PrinterUnitConvert.cs
- StructuralType.cs
- CompilationSection.cs
- PreviewPageInfo.cs
- ArraySortHelper.cs
- srgsitem.cs
- ThreadAttributes.cs
- BoundColumn.cs
- FormViewUpdatedEventArgs.cs
- documentsequencetextview.cs
- DataGridViewAutoSizeModeEventArgs.cs
- UserPreferenceChangingEventArgs.cs
- WebPartAuthorizationEventArgs.cs
- RuleSetReference.cs
- SerializerDescriptor.cs
- ButtonPopupAdapter.cs
- CompoundFileReference.cs
- DbModificationCommandTree.cs
- ChtmlCalendarAdapter.cs
- ImageConverter.cs
- HtmlButton.cs
- PathGradientBrush.cs
- ListBindingHelper.cs
- StickyNote.cs
- DownloadProgressEventArgs.cs
- KeyProperty.cs
- PieceDirectory.cs
- DiagnosticsConfigurationHandler.cs
- ConfigurationStrings.cs
- CookieProtection.cs
- OutputCacheProfileCollection.cs
- MD5CryptoServiceProvider.cs
- MutableAssemblyCacheEntry.cs
- DesignerForm.cs
- Win32SafeHandles.cs
- SrgsSubset.cs
- ContentFilePart.cs
- ComplexType.cs
- RegexTree.cs
- MetaData.cs
- MetadataArtifactLoaderCompositeFile.cs
- Triplet.cs
- TimeSpanMinutesConverter.cs
- CodeAccessSecurityEngine.cs
- FilterQueryOptionExpression.cs
- ProgressChangedEventArgs.cs
- NavigationProperty.cs
- XmlUtf8RawTextWriter.cs
- Expression.DebuggerProxy.cs
- CompatibleComparer.cs
- PropertySourceInfo.cs
- PersistencePipeline.cs
- MultiplexingDispatchMessageFormatter.cs
- NoneExcludedImageIndexConverter.cs
- MethodBody.cs
- OutputCacheModule.cs
- MediaSystem.cs
- ImageSourceTypeConverter.cs
- MailBnfHelper.cs
- FixedDocumentPaginator.cs
- ByteRangeDownloader.cs
- ProjectionRewriter.cs
- FixedSOMImage.cs
- DbMetaDataFactory.cs
- LongTypeConverter.cs
- SqlXml.cs
- ListView.cs
- InternalSafeNativeMethods.cs
- StatusBarItem.cs
- PropertyValidationContext.cs
- ArraySortHelper.cs
- BufferModesCollection.cs
- PageMediaSize.cs
- DigestTraceRecordHelper.cs
- FixedTextBuilder.cs
- SessionParameter.cs
- PtsHost.cs
- datacache.cs
- IntPtr.cs
- InternalConfigHost.cs
- UnsafeCollabNativeMethods.cs
- HtmlShimManager.cs
- DictionaryTraceRecord.cs
- CodeTypeDelegate.cs
- SafeRightsManagementHandle.cs
- Int32Storage.cs
- Win32SafeHandles.cs
- UnsafeNetInfoNativeMethods.cs
- ControlParser.cs
- SQLDateTime.cs
- ConnectionInterfaceCollection.cs
- KnownTypeAttribute.cs
- XmlMtomReader.cs
- ObjectListSelectEventArgs.cs
- QueryGeneratorBase.cs