Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ColumnResult.cs
- ConfigurationManager.cs
- NumberAction.cs
- DivideByZeroException.cs
- ClientFormsIdentity.cs
- Char.cs
- GPStream.cs
- PatternMatcher.cs
- WebBrowserContainer.cs
- TrackingMemoryStreamFactory.cs
- SchemaTableOptionalColumn.cs
- Symbol.cs
- SignedInfo.cs
- WindowsListViewItemCheckBox.cs
- KerberosTokenFactoryCredential.cs
- XmlSchemaExporter.cs
- NetworkInformationPermission.cs
- RsaKeyIdentifierClause.cs
- SynchronizedInputProviderWrapper.cs
- NegationPusher.cs
- Query.cs
- TreeViewImageKeyConverter.cs
- MarshalByValueComponent.cs
- MenuItemBindingCollection.cs
- DependencyPropertyKind.cs
- mediaclock.cs
- HtmlLink.cs
- XmlEntity.cs
- BlurBitmapEffect.cs
- ManagedFilter.cs
- XmlSchemaInclude.cs
- _SSPISessionCache.cs
- ProcessInfo.cs
- UIElementPropertyUndoUnit.cs
- StringSource.cs
- CellCreator.cs
- RuleSetBrowserDialog.cs
- AncillaryOps.cs
- GlyphRunDrawing.cs
- Math.cs
- Color.cs
- ActivityScheduledRecord.cs
- WindowsAuthenticationEventArgs.cs
- SQLInt32Storage.cs
- DrawingState.cs
- AdRotator.cs
- TableHeaderCell.cs
- Light.cs
- FunctionOverloadResolver.cs
- WebRequestModulesSection.cs
- EventLogPermission.cs
- PageStatePersister.cs
- DayRenderEvent.cs
- SequentialUshortCollection.cs
- DataGridViewTextBoxEditingControl.cs
- ReadOnlyActivityGlyph.cs
- ArraySegment.cs
- CustomWebEventKey.cs
- DesignerLabelAdapter.cs
- SRef.cs
- oledbmetadatacolumnnames.cs
- Byte.cs
- RectangleHotSpot.cs
- ProbeMatchesMessage11.cs
- ObjectKeyFrameCollection.cs
- DrawingContext.cs
- TextBoxLine.cs
- EditorZoneBase.cs
- RedistVersionInfo.cs
- ToolStripHighContrastRenderer.cs
- TerminatorSinks.cs
- ImageListImageEditor.cs
- ButtonFieldBase.cs
- ServicePointManagerElement.cs
- ProcessHost.cs
- XmlLangPropertyAttribute.cs
- GACMembershipCondition.cs
- MenuBase.cs
- IntSecurity.cs
- GeometryHitTestParameters.cs
- XmlHierarchicalEnumerable.cs
- ProcessModelSection.cs
- RequestDescription.cs
- WebBrowserEvent.cs
- MemberRelationshipService.cs
- GridViewPageEventArgs.cs
- TypeResolver.cs
- ProcessModuleCollection.cs
- ImageIndexConverter.cs
- PersistenceProviderElement.cs
- GraphicsContainer.cs
- InstanceKeyView.cs
- SerializationHelper.cs
- SessionState.cs
- InputBinding.cs
- DynamicResourceExtensionConverter.cs
- Array.cs
- ComplexBindingPropertiesAttribute.cs
- ReaderContextStackData.cs
- NavigationProperty.cs