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 / TextSerializer.cs / 1 / TextSerializer.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a serializer for text content. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { #region Namespaces. using System.Diagnostics; using System.IO; using System.Text; using System.Xml; #endregion Namespaces. ////// Provides support for serializing responses in text format. /// internal struct TextSerializer : IExceptionWriter { ///Writer to which output is sent. private readonly TextWriter writer; ///Initializes a new /// Stream to which output should be sent. /// Encoding to be used to write the result. internal TextSerializer(Stream output, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(encoding != null, "encoding != null"); this.writer = new StreamWriter(output, encoding); } ///for the specified stream. Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { XmlWriter xmlWriter = XmlWriter.Create(this.writer); ErrorHandler.SerializeXmlError(args, xmlWriter); this.writer.Flush(); } ///Handles the complete serialization for the specified content. /// Single Content to write.. ///internal void WriteRequest(object content) { Debug.Assert(content != null, "content != null"); string contentAsText; if (!System.Data.Services.Parsing.WebConvert.TryXmlPrimitiveToString(content, out contentAsText)) { throw new InvalidOperationException(Strings.Serializer_CannotConvertValue(content)); } Debug.Assert(contentAsText != null, "contentAsText != null"); this.writer.Write(contentAsText); this.writer.Flush(); } } } // 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 text content. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { #region Namespaces. using System.Diagnostics; using System.IO; using System.Text; using System.Xml; #endregion Namespaces. ////// Provides support for serializing responses in text format. /// internal struct TextSerializer : IExceptionWriter { ///Writer to which output is sent. private readonly TextWriter writer; ///Initializes a new /// Stream to which output should be sent. /// Encoding to be used to write the result. internal TextSerializer(Stream output, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(encoding != null, "encoding != null"); this.writer = new StreamWriter(output, encoding); } ///for the specified stream. Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { XmlWriter xmlWriter = XmlWriter.Create(this.writer); ErrorHandler.SerializeXmlError(args, xmlWriter); this.writer.Flush(); } ///Handles the complete serialization for the specified content. /// Single Content to write.. ///internal void WriteRequest(object content) { Debug.Assert(content != null, "content != null"); string contentAsText; if (!System.Data.Services.Parsing.WebConvert.TryXmlPrimitiveToString(content, out contentAsText)) { throw new InvalidOperationException(Strings.Serializer_CannotConvertValue(content)); } Debug.Assert(contentAsText != null, "contentAsText != null"); this.writer.Write(contentAsText); this.writer.Flush(); } } } // 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
- SecurityState.cs
- HtmlElement.cs
- GeometryGroup.cs
- XmlQualifiedName.cs
- NullableBoolConverter.cs
- TextParentUndoUnit.cs
- Int32Animation.cs
- DiscoveryVersionConverter.cs
- TimeSpanOrInfiniteConverter.cs
- TextParentUndoUnit.cs
- RoutingEndpointTrait.cs
- ToolStripRenderEventArgs.cs
- DataTrigger.cs
- Drawing.cs
- UIElement.cs
- SchemaElementDecl.cs
- XmlEventCache.cs
- InternalCache.cs
- TagPrefixInfo.cs
- ProfessionalColors.cs
- IItemContainerGenerator.cs
- ZipFileInfo.cs
- RequestSecurityToken.cs
- _IPv4Address.cs
- IndicFontClient.cs
- CheckBoxRenderer.cs
- PerformanceCounterPermission.cs
- SerializationFieldInfo.cs
- IfAction.cs
- XamlRtfConverter.cs
- CharStorage.cs
- KeyInterop.cs
- NetworkInterface.cs
- TextPatternIdentifiers.cs
- RoutedCommand.cs
- SerializationTrace.cs
- SQLDoubleStorage.cs
- DbConnectionPoolIdentity.cs
- Message.cs
- AnnouncementClient.cs
- AutomationPatternInfo.cs
- COM2Enum.cs
- ScriptingAuthenticationServiceSection.cs
- ContextStack.cs
- DropTarget.cs
- TransactionManager.cs
- WebPartRestoreVerb.cs
- OracleTransaction.cs
- ClonableStack.cs
- WebAdminConfigurationHelper.cs
- RegisterInfo.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- Environment.cs
- EntityTypeBase.cs
- RoleServiceManager.cs
- BlurEffect.cs
- Reference.cs
- ComponentGuaranteesAttribute.cs
- StrongTypingException.cs
- DBParameter.cs
- BindingRestrictions.cs
- LayoutTableCell.cs
- XmlNodeChangedEventArgs.cs
- BinaryReader.cs
- COSERVERINFO.cs
- ListControl.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- NotImplementedException.cs
- ConfigurationErrorsException.cs
- UmAlQuraCalendar.cs
- nulltextnavigator.cs
- MessageLoggingElement.cs
- TypeDescriptorFilterService.cs
- MergeLocalizationDirectives.cs
- VisualStateGroup.cs
- HttpResponseBase.cs
- Utils.cs
- SqlTriggerContext.cs
- OperatingSystemVersionCheck.cs
- FixedTextBuilder.cs
- DispatcherHookEventArgs.cs
- DoWorkEventArgs.cs
- JulianCalendar.cs
- WebPartDescriptionCollection.cs
- InputGestureCollection.cs
- Storyboard.cs
- OdbcInfoMessageEvent.cs
- RequestCacheManager.cs
- CachedTypeface.cs
- _emptywebproxy.cs
- LazyTextWriterCreator.cs
- PriorityQueue.cs
- Stackframe.cs
- FamilyTypefaceCollection.cs
- XmlUtilWriter.cs
- Globals.cs
- MasterPage.cs
- ComAdminWrapper.cs
- StyleHelper.cs
- Int64Converter.cs