Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / DataServiceRequestArgs.cs / 1305376 / DataServiceRequestArgs.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// This class represents additional metadata to be applied to a request
// sent from the client to a data service.
//
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
using System.Collections.Generic;
///
/// This class represent additional metadata to be applied to a request
/// sent from the client to a data service.
///
public class DataServiceRequestArgs
{
///
/// The headers collection for the request.
/// This is just a storage, no validation is done on this.
///
private readonly Dictionary headers;
///
/// Constructs a new DataServiceRequestArgs instance
///
public DataServiceRequestArgs()
{
this.headers = new Dictionary(EqualityComparer.Default);
}
///
/// Sets the mime type (ex. image/png) to be used when retrieving the stream.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Accept header.
///
public string AcceptContentType
{
get { return this.GetHeaderValue(XmlConstants.HttpRequestAccept); }
set { this.SetHeaderValue(XmlConstants.HttpRequestAccept, value); }
}
///
/// Sets the Content-Type header to be used when sending the stream to the server.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Content-Type header.
///
public string ContentType
{
get { return this.GetHeaderValue(XmlConstants.HttpContentType); }
set { this.SetHeaderValue(XmlConstants.HttpContentType, value); }
}
///
/// Sets the Slug header to be used when sending the stream to the server.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Slug header.
///
public string Slug
{
get { return this.GetHeaderValue(XmlConstants.HttpSlug); }
set { this.SetHeaderValue(XmlConstants.HttpSlug, value); }
}
///
/// Dictionary containing all the request headers to be used when retrieving the stream.
/// The user should take care so as to not alter an HTTP header which will change
/// the meaning of the request.
/// No validation is performed on the header names or values.
/// This class will not attempt to fix up any of the headers specified and
/// will try to use them "as is".
///
public Dictionary Headers
{
get { return this.headers; }
}
///
/// Helper to return a value of the header.
///
/// The name of the header to get.
/// The value of the header or null if the header is not set.
private string GetHeaderValue(string header)
{
string value;
if (!this.headers.TryGetValue(header, out value))
{
return null;
}
return value;
}
///
/// Helper to set a value of the header
///
/// The name of the header to set.
/// The value to set for the header. If this is null the header will be removed.
private void SetHeaderValue(string header, string value)
{
if (value == null)
{
if (this.headers.ContainsKey(header))
{
this.headers.Remove(header);
}
}
else
{
this.headers[header] = value;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// This class represents additional metadata to be applied to a request
// sent from the client to a data service.
//
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
using System.Collections.Generic;
///
/// This class represent additional metadata to be applied to a request
/// sent from the client to a data service.
///
public class DataServiceRequestArgs
{
///
/// The headers collection for the request.
/// This is just a storage, no validation is done on this.
///
private readonly Dictionary headers;
///
/// Constructs a new DataServiceRequestArgs instance
///
public DataServiceRequestArgs()
{
this.headers = new Dictionary(EqualityComparer.Default);
}
///
/// Sets the mime type (ex. image/png) to be used when retrieving the stream.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Accept header.
///
public string AcceptContentType
{
get { return this.GetHeaderValue(XmlConstants.HttpRequestAccept); }
set { this.SetHeaderValue(XmlConstants.HttpRequestAccept, value); }
}
///
/// Sets the Content-Type header to be used when sending the stream to the server.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Content-Type header.
///
public string ContentType
{
get { return this.GetHeaderValue(XmlConstants.HttpContentType); }
set { this.SetHeaderValue(XmlConstants.HttpContentType, value); }
}
///
/// Sets the Slug header to be used when sending the stream to the server.
/// Note that no validation is done on the contents of this property.
/// It is the responsibility of the user to format it correctly to be used
/// as the value of an HTTP Slug header.
///
public string Slug
{
get { return this.GetHeaderValue(XmlConstants.HttpSlug); }
set { this.SetHeaderValue(XmlConstants.HttpSlug, value); }
}
///
/// Dictionary containing all the request headers to be used when retrieving the stream.
/// The user should take care so as to not alter an HTTP header which will change
/// the meaning of the request.
/// No validation is performed on the header names or values.
/// This class will not attempt to fix up any of the headers specified and
/// will try to use them "as is".
///
public Dictionary Headers
{
get { return this.headers; }
}
///
/// Helper to return a value of the header.
///
/// The name of the header to get.
/// The value of the header or null if the header is not set.
private string GetHeaderValue(string header)
{
string value;
if (!this.headers.TryGetValue(header, out value))
{
return null;
}
return value;
}
///
/// Helper to set a value of the header
///
/// The name of the header to set.
/// The value to set for the header. If this is null the header will be removed.
private void SetHeaderValue(string header, string value)
{
if (value == null)
{
if (this.headers.ContainsKey(header))
{
this.headers.Remove(header);
}
}
else
{
this.headers[header] = value;
}
}
}
}
// 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
- ContractNamespaceAttribute.cs
- SchemaUtility.cs
- PageAdapter.cs
- FirstMatchCodeGroup.cs
- TimeoutHelper.cs
- HttpTransportSecurity.cs
- EventLogPropertySelector.cs
- WebConfigManager.cs
- VirtualizedItemPattern.cs
- RefreshPropertiesAttribute.cs
- ProviderSettings.cs
- SystemResourceHost.cs
- FormatSettings.cs
- EntitySetBase.cs
- UnSafeCharBuffer.cs
- RoutingExtension.cs
- ScrollContentPresenter.cs
- HasCopySemanticsAttribute.cs
- CompiledXpathExpr.cs
- DateTimeUtil.cs
- Subtree.cs
- validation.cs
- RandomNumberGenerator.cs
- PageAsyncTaskManager.cs
- DriveNotFoundException.cs
- EntityContainerEntitySet.cs
- ReturnType.cs
- RestClientProxyHandler.cs
- UpdateManifestForBrowserApplication.cs
- TextEditorCopyPaste.cs
- DataGridViewColumnConverter.cs
- ClrPerspective.cs
- LinkArea.cs
- Errors.cs
- TreeChangeInfo.cs
- ServiceEndpoint.cs
- UnsafeNativeMethodsMilCoreApi.cs
- EntityStoreSchemaFilterEntry.cs
- NonClientArea.cs
- TableItemPattern.cs
- ProjectedSlot.cs
- SharedConnectionWorkflowTransactionService.cs
- UniqueContractNameValidationBehavior.cs
- DesignSurfaceServiceContainer.cs
- BitmapSource.cs
- CompilerHelpers.cs
- WindowPatternIdentifiers.cs
- BatchWriter.cs
- TextLineResult.cs
- Fonts.cs
- RenderDataDrawingContext.cs
- SiteMapProvider.cs
- PropertyDescriptors.cs
- StackSpiller.Bindings.cs
- GeometryDrawing.cs
- FixedPageAutomationPeer.cs
- AdPostCacheSubstitution.cs
- ColumnReorderedEventArgs.cs
- ToolTipService.cs
- TrackingStringDictionary.cs
- CfgParser.cs
- SecurityDocument.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ADMembershipUser.cs
- DataPagerCommandEventArgs.cs
- XmlQueryRuntime.cs
- CollectionsUtil.cs
- BitStream.cs
- EngineSite.cs
- FixedDSBuilder.cs
- TextServicesHost.cs
- NotConverter.cs
- LocalizationCodeDomSerializer.cs
- RuntimeWrappedException.cs
- PictureBox.cs
- XmlSerializationWriter.cs
- PartialArray.cs
- ManipulationCompletedEventArgs.cs
- RbTree.cs
- RepeaterItemEventArgs.cs
- CompModSwitches.cs
- DataListItemEventArgs.cs
- WebPartConnectionsCloseVerb.cs
- XmlValueConverter.cs
- WindowsStreamSecurityBindingElement.cs
- KeySplineConverter.cs
- XmlConverter.cs
- Html32TextWriter.cs
- ApplicationGesture.cs
- DataSysAttribute.cs
- UnauthorizedAccessException.cs
- DataBindEngine.cs
- ObjectDataSourceEventArgs.cs
- LoginCancelEventArgs.cs
- HierarchicalDataSourceControl.cs
- DelegatingConfigHost.cs
- LabelDesigner.cs
- InlineCollection.cs
- InvalidPrinterException.cs
- StyleXamlParser.cs