Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / JsonServiceDocumentSerializer.cs / 1 / JsonServiceDocumentSerializer.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a serializer for the Json Service Document format. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { using System.Data.Services.Providers; using System.Diagnostics; using System.IO; using System.Text; ////// Provides support for serializing service models as /// a Service Document. /// [DebuggerDisplay("JsonServiceDocumentSerializer={baseUri}")] internal sealed class JsonServiceDocumentSerializer : IExceptionWriter { ///JsonWriter to write out strings in Json format. private readonly JsonWriter writer; ///Data provider from which metadata should be gathered. private readonly IDataServiceProvider provider; ///Element name for the json service document. private const string JsonEntitySetsElementName = "EntitySets"; ////// Initializes a new JsonServiceDocumentSerializer, ready to write /// out the Service Document for a data provider. /// /// Stream to which output should be sent. /// Data provider from which metadata should be gathered. /// Text encoding for the response. internal JsonServiceDocumentSerializer( Stream output, IDataServiceProvider provider, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(provider != null, "provider != null"); StreamWriter writer = new StreamWriter(output, encoding); this.writer = new JsonWriter(writer); this.provider = provider; } ///Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { ErrorHandler.SerializeJsonError(args, this.writer); } ///Writes the Service Document to the output stream. internal void WriteRequest() { try { this.writer.StartWrapper(); this.writer.StartObjectScope(); this.writer.WriteName(JsonEntitySetsElementName); this.writer.StartArrayScope(); foreach (ResourceContainer container in this.provider.GetContainers()) { this.writer.WriteValue(container.Name); } this.writer.EndScope(); // end the array scope this.writer.EndScope(); // end the object scope this.writer.EndWrapper(); } finally { this.writer.Flush(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a serializer for the Json Service Document format. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { using System.Data.Services.Providers; using System.Diagnostics; using System.IO; using System.Text; ////// Provides support for serializing service models as /// a Service Document. /// [DebuggerDisplay("JsonServiceDocumentSerializer={baseUri}")] internal sealed class JsonServiceDocumentSerializer : IExceptionWriter { ///JsonWriter to write out strings in Json format. private readonly JsonWriter writer; ///Data provider from which metadata should be gathered. private readonly IDataServiceProvider provider; ///Element name for the json service document. private const string JsonEntitySetsElementName = "EntitySets"; ////// Initializes a new JsonServiceDocumentSerializer, ready to write /// out the Service Document for a data provider. /// /// Stream to which output should be sent. /// Data provider from which metadata should be gathered. /// Text encoding for the response. internal JsonServiceDocumentSerializer( Stream output, IDataServiceProvider provider, Encoding encoding) { Debug.Assert(output != null, "output != null"); Debug.Assert(provider != null, "provider != null"); StreamWriter writer = new StreamWriter(output, encoding); this.writer = new JsonWriter(writer); this.provider = provider; } ///Serializes exception information. /// Description of exception to serialize. public void WriteException(HandleExceptionArgs args) { ErrorHandler.SerializeJsonError(args, this.writer); } ///Writes the Service Document to the output stream. internal void WriteRequest() { try { this.writer.StartWrapper(); this.writer.StartObjectScope(); this.writer.WriteName(JsonEntitySetsElementName); this.writer.StartArrayScope(); foreach (ResourceContainer container in this.provider.GetContainers()) { this.writer.WriteValue(container.Name); } this.writer.EndScope(); // end the array scope this.writer.EndScope(); // end the object scope this.writer.EndWrapper(); } finally { this.writer.Flush(); } } } } // 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
- ObjectSelectorEditor.cs
- PageEventArgs.cs
- SystemWebCachingSectionGroup.cs
- BindingCompleteEventArgs.cs
- XmlSchemaAttribute.cs
- OutputCacheSettingsSection.cs
- _ConnectionGroup.cs
- ListComponentEditor.cs
- ContentDesigner.cs
- CommonObjectSecurity.cs
- SafeNativeMethodsCLR.cs
- JsonGlobals.cs
- CreateUserWizardAutoFormat.cs
- PageRouteHandler.cs
- HitTestWithPointDrawingContextWalker.cs
- Repeater.cs
- RepeaterDataBoundAdapter.cs
- FileDialog_Vista.cs
- securitycriticaldataClass.cs
- XPathAxisIterator.cs
- UpdateProgress.cs
- AlphabeticalEnumConverter.cs
- TextEvent.cs
- EventWaitHandleSecurity.cs
- Unit.cs
- MediaContextNotificationWindow.cs
- RecoverInstanceLocksCommand.cs
- AsyncInvokeOperation.cs
- SelectedGridItemChangedEvent.cs
- EventRouteFactory.cs
- RowToParametersTransformer.cs
- HttpContextBase.cs
- SelectingProviderEventArgs.cs
- ResourceExpression.cs
- ThreadPoolTaskScheduler.cs
- RadioButtonBaseAdapter.cs
- NotifyInputEventArgs.cs
- Image.cs
- BlockExpression.cs
- PageWrapper.cs
- Point4D.cs
- SelectionProviderWrapper.cs
- DiscoveryMessageSequence11.cs
- Thumb.cs
- NullableDecimalAverageAggregationOperator.cs
- HTMLTagNameToTypeMapper.cs
- CodeGroup.cs
- _ChunkParse.cs
- TrackingServices.cs
- WindowsListViewGroupHelper.cs
- WebPartConnection.cs
- WebPartZoneCollection.cs
- DataGridViewRowPostPaintEventArgs.cs
- CompilerWrapper.cs
- ControlBuilderAttribute.cs
- uribuilder.cs
- ComponentConverter.cs
- BamlReader.cs
- StandardToolWindows.cs
- ChildrenQuery.cs
- DefaultBindingPropertyAttribute.cs
- InternalCache.cs
- ObsoleteAttribute.cs
- XmlSchemaExporter.cs
- SpecialNameAttribute.cs
- InvalidCastException.cs
- SQLConvert.cs
- DataFormats.cs
- System.Data_BID.cs
- GridViewPageEventArgs.cs
- DataErrorValidationRule.cs
- HMAC.cs
- DispatcherObject.cs
- LinkButton.cs
- MultiBinding.cs
- TextSchema.cs
- StylusPointPropertyInfo.cs
- WebBrowserProgressChangedEventHandler.cs
- Axis.cs
- Attributes.cs
- MasterPageBuildProvider.cs
- BackgroundFormatInfo.cs
- WebRequest.cs
- ValueProviderWrapper.cs
- ToolStripComboBox.cs
- EntityDesignerDataSourceView.cs
- PackageRelationshipCollection.cs
- PolyBezierSegment.cs
- ReversePositionQuery.cs
- DelimitedListTraceListener.cs
- LaxModeSecurityHeaderElementInferenceEngine.cs
- DataGridViewAutoSizeModeEventArgs.cs
- UpdatePanel.cs
- AutoResetEvent.cs
- XmlQueryType.cs
- XmlReader.cs
- TextServicesCompartmentContext.cs
- DigitShape.cs
- XslNumber.cs
- KeyedByTypeCollection.cs