Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / XmlDocumentSerializer.cs / 1305376 / XmlDocumentSerializer.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a serializer for the Atom Service Document format.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Serializers
{
using System;
using System.Data.Services.Providers;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
/// Provides support for serializing generic XML documents.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Pending review.")]
[DebuggerDisplay("XmlDocumentSerializer={baseUri}")]
internal abstract class XmlDocumentSerializer : IExceptionWriter
{
/// Base URI from which resources should be resolved.
private readonly Uri baseUri;
/// Data provider from which metadata should be gathered.
private readonly DataServiceProviderWrapper provider;
/// Writer to which output is sent.
private readonly XmlWriter writer;
///
/// Initializes a new XmlDocumentSerializer, ready to write
/// out an XML document
///
/// Stream to which output should be sent.
/// Base URI from which resources should be resolved.
/// Data provider from which metadata should be gathered.
/// Text encoding for the response.
internal XmlDocumentSerializer(
Stream output,
Uri baseUri,
DataServiceProviderWrapper provider,
Encoding encoding)
{
Debug.Assert(output != null, "output != null");
Debug.Assert(provider != null, "provider != null");
Debug.Assert(baseUri != null, "baseUri != null");
Debug.Assert(encoding != null, "encoding != null");
Debug.Assert(baseUri.IsAbsoluteUri, "baseUri.IsAbsoluteUri(" + baseUri + ")");
Debug.Assert(baseUri.AbsoluteUri[baseUri.AbsoluteUri.Length - 1] == '/', "baseUri(" + baseUri.AbsoluteUri + ") ends with '/'");
this.writer = XmlUtil.CreateXmlWriterAndWriteProcessingInstruction(output, encoding);
this.provider = provider;
this.baseUri = baseUri;
}
/// Base URI from which resources should be resolved.
protected Uri BaseUri
{
get { return this.baseUri; }
}
/// Data provider from which metadata should be gathered.
protected DataServiceProviderWrapper Provider
{
get { return this.provider; }
}
/// Writer to which output is sent.
protected XmlWriter Writer
{
get { return this.writer; }
}
/// Serializes exception information.
/// Description of exception to serialize.
public void WriteException(HandleExceptionArgs args)
{
ErrorHandler.SerializeXmlError(args, this.writer);
}
/// Writes the document for this request..
/// Data service instance.
internal abstract void WriteRequest(IDataService service);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a serializer for the Atom Service Document format.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Serializers
{
using System;
using System.Data.Services.Providers;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
/// Provides support for serializing generic XML documents.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Pending review.")]
[DebuggerDisplay("XmlDocumentSerializer={baseUri}")]
internal abstract class XmlDocumentSerializer : IExceptionWriter
{
/// Base URI from which resources should be resolved.
private readonly Uri baseUri;
/// Data provider from which metadata should be gathered.
private readonly DataServiceProviderWrapper provider;
/// Writer to which output is sent.
private readonly XmlWriter writer;
///
/// Initializes a new XmlDocumentSerializer, ready to write
/// out an XML document
///
/// Stream to which output should be sent.
/// Base URI from which resources should be resolved.
/// Data provider from which metadata should be gathered.
/// Text encoding for the response.
internal XmlDocumentSerializer(
Stream output,
Uri baseUri,
DataServiceProviderWrapper provider,
Encoding encoding)
{
Debug.Assert(output != null, "output != null");
Debug.Assert(provider != null, "provider != null");
Debug.Assert(baseUri != null, "baseUri != null");
Debug.Assert(encoding != null, "encoding != null");
Debug.Assert(baseUri.IsAbsoluteUri, "baseUri.IsAbsoluteUri(" + baseUri + ")");
Debug.Assert(baseUri.AbsoluteUri[baseUri.AbsoluteUri.Length - 1] == '/', "baseUri(" + baseUri.AbsoluteUri + ") ends with '/'");
this.writer = XmlUtil.CreateXmlWriterAndWriteProcessingInstruction(output, encoding);
this.provider = provider;
this.baseUri = baseUri;
}
/// Base URI from which resources should be resolved.
protected Uri BaseUri
{
get { return this.baseUri; }
}
/// Data provider from which metadata should be gathered.
protected DataServiceProviderWrapper Provider
{
get { return this.provider; }
}
/// Writer to which output is sent.
protected XmlWriter Writer
{
get { return this.writer; }
}
/// Serializes exception information.
/// Description of exception to serialize.
public void WriteException(HandleExceptionArgs args)
{
ErrorHandler.SerializeXmlError(args, this.writer);
}
/// Writes the document for this request..
/// Data service instance.
internal abstract void WriteRequest(IDataService service);
}
}
// 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
- VolatileEnlistmentMultiplexing.cs
- StrokeCollection.cs
- TextBoxRenderer.cs
- WebDescriptionAttribute.cs
- SystemSounds.cs
- Point4D.cs
- AttributeExtensions.cs
- UnicodeEncoding.cs
- NativeMethods.cs
- ContainerVisual.cs
- TagPrefixCollection.cs
- SupportingTokenBindingElement.cs
- ArrangedElementCollection.cs
- MouseOverProperty.cs
- EntityProviderFactory.cs
- EventHandlingScope.cs
- TypeUtil.cs
- Vector.cs
- SerializableTypeCodeDomSerializer.cs
- EventLogTraceListener.cs
- SchemaTypeEmitter.cs
- XslException.cs
- FormViewCommandEventArgs.cs
- FixedTextPointer.cs
- odbcmetadatafactory.cs
- InvalidCastException.cs
- TransformProviderWrapper.cs
- DbParameterCollectionHelper.cs
- ReadOnlyCollectionBase.cs
- RequestResizeEvent.cs
- infer.cs
- WebPartVerb.cs
- Evidence.cs
- _ShellExpression.cs
- WebPartManager.cs
- MenuItemBindingCollection.cs
- AstTree.cs
- XmlComplianceUtil.cs
- TrustManager.cs
- ScriptReferenceEventArgs.cs
- Operator.cs
- CodeObjectCreateExpression.cs
- CrossAppDomainChannel.cs
- UpdateCommand.cs
- WebPartsPersonalization.cs
- MemberAccessException.cs
- EtwTrace.cs
- ToolbarAUtomationPeer.cs
- RandomDelaySendsAsyncResult.cs
- DependencyPropertyKey.cs
- ImageAttributes.cs
- Invariant.cs
- SqlCommandSet.cs
- WindowsAltTab.cs
- ConfigurationErrorsException.cs
- RadioButton.cs
- MsmqBindingElementBase.cs
- PhonemeEventArgs.cs
- ServiceNotStartedException.cs
- ReceiveContext.cs
- Configuration.cs
- SpotLight.cs
- ImmutablePropertyDescriptorGridEntry.cs
- AtomMaterializer.cs
- ClientTargetSection.cs
- ToolTipService.cs
- TextBoxBaseDesigner.cs
- Int32CollectionConverter.cs
- PersonalizationStateInfoCollection.cs
- XmlChoiceIdentifierAttribute.cs
- SuppressIldasmAttribute.cs
- AuthenticationManager.cs
- ByteStreamBufferedMessageData.cs
- Pen.cs
- BrowserCapabilitiesCodeGenerator.cs
- MessageSmuggler.cs
- CallSiteHelpers.cs
- RelationshipManager.cs
- wgx_exports.cs
- DbParameterHelper.cs
- CrossAppDomainChannel.cs
- WsdlBuildProvider.cs
- TypeConverterMarkupExtension.cs
- JsonByteArrayDataContract.cs
- Int32CAMarshaler.cs
- DeploymentSectionCache.cs
- CommonXSendMessage.cs
- XmlNodeList.cs
- EntityDataSourceEntitySetNameItem.cs
- MouseGesture.cs
- XmlAnyAttributeAttribute.cs
- SharedConnectionWorkflowTransactionService.cs
- AuthStoreRoleProvider.cs
- DeviceFilterDictionary.cs
- SerializationStore.cs
- RawStylusSystemGestureInputReport.cs
- ErrorHandler.cs
- WebServiceClientProxyGenerator.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- OleDbConnection.cs