Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / AtomEntry.cs / 1407647 / AtomEntry.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a class to represent an ATOM entry as parsed and as it
// goes through the materialization pipeline.
//
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
#region Namespaces.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
using System.Text;
#endregion Namespaces.
///
/// Use this class to represent an entry in an ATOM payload as it
/// goes through the WCF Data Services materialization pipeline.
///
///
/// Different properties are set on instances of this type at different
/// points during its lifetime.
///
[DebuggerDisplay("AtomEntry {ResolvedObject} @ {Identity}")]
internal class AtomEntry
{
#region Private fields.
/// Entry flags.
private EntryFlags flags;
///
/// Masks used get/set the status of the entry
///
[Flags]
private enum EntryFlags
{
/// Bitmask for ShouldUpdateFromPayload flag.
ShouldUpdateFromPayload = 0x01,
/// Bitmask for CreatedByMaterializer flag.
CreatedByMaterializer = 0x02,
/// Bitmask for EntityHasBeenResolved flag.
EntityHasBeenResolved = 0x04,
/// Bitmask for MediaLinkEntry flag (value).
MediaLinkEntryValue = 0x08,
/// Bitmask for MediaLinkEntry flag (assigned/non-null state).
MediaLinkEntryAssigned = 0x10,
/// Bitmask for EntityPropertyMappingsApplied flag.
EntityPropertyMappingsApplied = 0x20,
/// Bitmask for IsNull flag.
IsNull = 0x40
}
#endregion Private fields.
#region Public properties.
/// MediaLinkEntry. Valid after data values applies.
public bool? MediaLinkEntry
{
get
{
return this.GetFlagValue(EntryFlags.MediaLinkEntryAssigned) ? (bool?)this.GetFlagValue(EntryFlags.MediaLinkEntryValue) : null;
}
set
{
Debug.Assert(value.HasValue, "value.HasValue -- callers shouldn't set the value to unknown");
this.SetFlagValue(EntryFlags.MediaLinkEntryAssigned, true);
this.SetFlagValue(EntryFlags.MediaLinkEntryValue, value.Value);
}
}
/// URI for media content. null if MediaLinkEntry is false.
public Uri MediaContentUri
{
get;
set;
}
/// URI for editing media. null if MediaLinkEntry is false.
public Uri MediaEditUri
{
get;
set;
}
/// Type name, as present in server payload.
public string TypeName
{
get;
set;
}
/// Actual type of the ResolvedObject.
public ClientType ActualType
{
get;
set;
}
/// Edit link for the ATOM entry - basically link used to update the entity.
public Uri EditLink
{
get;
set;
}
/// Self link for the ATOM entry - basically link used to query the entity.
public Uri QueryLink
{
get;
set;
}
///
/// Identity link for the ATOM entry.
/// This is set by the parser (guaranteed, fails to parser if not available on entry).
///
public string Identity
{
get;
set;
}
///
/// Whether the entry is a null.
/// This is set by the parser only on inlined entries, as it's invalid ATOM in
/// top-level cases.
///
public bool IsNull
{
get { return this.GetFlagValue(EntryFlags.IsNull); }
set { this.SetFlagValue(EntryFlags.IsNull, value); }
}
/// Data names and values.
public List DataValues
{
get;
set;
}
/// Resolved object.
public object ResolvedObject
{
get;
set;
}
/// Tag for the entry, set by the parser when an entry callback is invoked.
public object Tag
{
get;
set;
}
/// Text for Etag, possibly null.
public string ETagText
{
get;
set;
}
/// Text for ETag corresponding to media resource for this entry.
public string StreamETagText
{
get;
set;
}
/// Whether values should be updated from payload.
public bool ShouldUpdateFromPayload
{
get { return this.GetFlagValue(EntryFlags.ShouldUpdateFromPayload); }
set { this.SetFlagValue(EntryFlags.ShouldUpdateFromPayload, value); }
}
/// Whether the materializer has created the ResolvedObject instance.
public bool CreatedByMaterializer
{
get { return this.GetFlagValue(EntryFlags.CreatedByMaterializer); }
set { this.SetFlagValue(EntryFlags.CreatedByMaterializer, value); }
}
/// Whether the entity has been resolved / created.
public bool EntityHasBeenResolved
{
get { return this.GetFlagValue(EntryFlags.EntityHasBeenResolved); }
set { this.SetFlagValue(EntryFlags.EntityHasBeenResolved, value); }
}
/// Whether entity Property Mappings (a.k.a. friendly feeds) have been applied to this entry if applicable.
public bool EntityPropertyMappingsApplied
{
get { return this.GetFlagValue(EntryFlags.EntityPropertyMappingsApplied); }
set { this.SetFlagValue(EntryFlags.EntityPropertyMappingsApplied, value); }
}
#endregion Public properties.
#region Private methods.
/// Gets the value for a masked item.
/// Mask value.
/// true if the flag is set; false otherwise.
private bool GetFlagValue(EntryFlags mask)
{
return (this.flags & mask) != 0;
}
/// Sets the value for a masked item.
/// Mask value.
/// Value to set
private void SetFlagValue(EntryFlags mask, bool value)
{
if (value)
{
this.flags |= mask;
}
else
{
this.flags &= (~mask);
}
}
#endregion Private methods.
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a class to represent an ATOM entry as parsed and as it
// goes through the materialization pipeline.
//
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
#region Namespaces.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
using System.Text;
#endregion Namespaces.
///
/// Use this class to represent an entry in an ATOM payload as it
/// goes through the WCF Data Services materialization pipeline.
///
///
/// Different properties are set on instances of this type at different
/// points during its lifetime.
///
[DebuggerDisplay("AtomEntry {ResolvedObject} @ {Identity}")]
internal class AtomEntry
{
#region Private fields.
/// Entry flags.
private EntryFlags flags;
///
/// Masks used get/set the status of the entry
///
[Flags]
private enum EntryFlags
{
/// Bitmask for ShouldUpdateFromPayload flag.
ShouldUpdateFromPayload = 0x01,
/// Bitmask for CreatedByMaterializer flag.
CreatedByMaterializer = 0x02,
/// Bitmask for EntityHasBeenResolved flag.
EntityHasBeenResolved = 0x04,
/// Bitmask for MediaLinkEntry flag (value).
MediaLinkEntryValue = 0x08,
/// Bitmask for MediaLinkEntry flag (assigned/non-null state).
MediaLinkEntryAssigned = 0x10,
/// Bitmask for EntityPropertyMappingsApplied flag.
EntityPropertyMappingsApplied = 0x20,
/// Bitmask for IsNull flag.
IsNull = 0x40
}
#endregion Private fields.
#region Public properties.
/// MediaLinkEntry. Valid after data values applies.
public bool? MediaLinkEntry
{
get
{
return this.GetFlagValue(EntryFlags.MediaLinkEntryAssigned) ? (bool?)this.GetFlagValue(EntryFlags.MediaLinkEntryValue) : null;
}
set
{
Debug.Assert(value.HasValue, "value.HasValue -- callers shouldn't set the value to unknown");
this.SetFlagValue(EntryFlags.MediaLinkEntryAssigned, true);
this.SetFlagValue(EntryFlags.MediaLinkEntryValue, value.Value);
}
}
/// URI for media content. null if MediaLinkEntry is false.
public Uri MediaContentUri
{
get;
set;
}
/// URI for editing media. null if MediaLinkEntry is false.
public Uri MediaEditUri
{
get;
set;
}
/// Type name, as present in server payload.
public string TypeName
{
get;
set;
}
/// Actual type of the ResolvedObject.
public ClientType ActualType
{
get;
set;
}
/// Edit link for the ATOM entry - basically link used to update the entity.
public Uri EditLink
{
get;
set;
}
/// Self link for the ATOM entry - basically link used to query the entity.
public Uri QueryLink
{
get;
set;
}
///
/// Identity link for the ATOM entry.
/// This is set by the parser (guaranteed, fails to parser if not available on entry).
///
public string Identity
{
get;
set;
}
///
/// Whether the entry is a null.
/// This is set by the parser only on inlined entries, as it's invalid ATOM in
/// top-level cases.
///
public bool IsNull
{
get { return this.GetFlagValue(EntryFlags.IsNull); }
set { this.SetFlagValue(EntryFlags.IsNull, value); }
}
/// Data names and values.
public List DataValues
{
get;
set;
}
/// Resolved object.
public object ResolvedObject
{
get;
set;
}
/// Tag for the entry, set by the parser when an entry callback is invoked.
public object Tag
{
get;
set;
}
/// Text for Etag, possibly null.
public string ETagText
{
get;
set;
}
/// Text for ETag corresponding to media resource for this entry.
public string StreamETagText
{
get;
set;
}
/// Whether values should be updated from payload.
public bool ShouldUpdateFromPayload
{
get { return this.GetFlagValue(EntryFlags.ShouldUpdateFromPayload); }
set { this.SetFlagValue(EntryFlags.ShouldUpdateFromPayload, value); }
}
/// Whether the materializer has created the ResolvedObject instance.
public bool CreatedByMaterializer
{
get { return this.GetFlagValue(EntryFlags.CreatedByMaterializer); }
set { this.SetFlagValue(EntryFlags.CreatedByMaterializer, value); }
}
/// Whether the entity has been resolved / created.
public bool EntityHasBeenResolved
{
get { return this.GetFlagValue(EntryFlags.EntityHasBeenResolved); }
set { this.SetFlagValue(EntryFlags.EntityHasBeenResolved, value); }
}
/// Whether entity Property Mappings (a.k.a. friendly feeds) have been applied to this entry if applicable.
public bool EntityPropertyMappingsApplied
{
get { return this.GetFlagValue(EntryFlags.EntityPropertyMappingsApplied); }
set { this.SetFlagValue(EntryFlags.EntityPropertyMappingsApplied, value); }
}
#endregion Public properties.
#region Private methods.
/// Gets the value for a masked item.
/// Mask value.
/// true if the flag is set; false otherwise.
private bool GetFlagValue(EntryFlags mask)
{
return (this.flags & mask) != 0;
}
/// Sets the value for a masked item.
/// Mask value.
/// Value to set
private void SetFlagValue(EntryFlags mask, bool value)
{
if (value)
{
this.flags |= mask;
}
else
{
this.flags &= (~mask);
}
}
#endregion Private methods.
}
}
// 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
- WorkflowServiceAttributesTypeConverter.cs
- AutomationProperties.cs
- _NetRes.cs
- OdbcInfoMessageEvent.cs
- PropertyDescriptors.cs
- GridItem.cs
- UnmanagedBitmapWrapper.cs
- TextProviderWrapper.cs
- FileSystemInfo.cs
- GridViewRowCollection.cs
- DialogResultConverter.cs
- Attachment.cs
- SqlCacheDependencySection.cs
- WindowsAuthenticationEventArgs.cs
- ListSortDescriptionCollection.cs
- RegistrySecurity.cs
- TransformGroup.cs
- PreservationFileWriter.cs
- CodeCatchClause.cs
- ISAPIRuntime.cs
- WebPartEditVerb.cs
- ContentFileHelper.cs
- TextSelectionHelper.cs
- DataContractSerializerServiceBehavior.cs
- Helper.cs
- MissingFieldException.cs
- WebInvokeAttribute.cs
- DomNameTable.cs
- NavigationCommands.cs
- ObjectStateManagerMetadata.cs
- DynamicPropertyHolder.cs
- MergePropertyDescriptor.cs
- TextDecoration.cs
- SqlCommandSet.cs
- DelimitedListTraceListener.cs
- DataGridViewCell.cs
- PathSegmentCollection.cs
- LabelAutomationPeer.cs
- TripleDES.cs
- CacheChildrenQuery.cs
- SetStoryboardSpeedRatio.cs
- FixedElement.cs
- Action.cs
- FixedFlowMap.cs
- VariableDesigner.xaml.cs
- RegistrationContext.cs
- DecoratedNameAttribute.cs
- SecureConversationSecurityTokenParameters.cs
- ApplicationDirectoryMembershipCondition.cs
- IHttpResponseInternal.cs
- ThreadExceptionEvent.cs
- SettingsContext.cs
- ComponentResourceKey.cs
- SQLDouble.cs
- MapPathBasedVirtualPathProvider.cs
- XmlComplianceUtil.cs
- IISMapPath.cs
- StrongName.cs
- SessionStateModule.cs
- GridViewColumnCollection.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- DispatcherTimer.cs
- BinaryMessageFormatter.cs
- SystemResourceHost.cs
- NominalTypeEliminator.cs
- ArraySubsetEnumerator.cs
- CheckBoxRenderer.cs
- SqlProfileProvider.cs
- TTSEvent.cs
- RefreshEventArgs.cs
- StringUtil.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- TemplateBamlRecordReader.cs
- hresults.cs
- SqlCacheDependency.cs
- TemplateKey.cs
- RowCache.cs
- controlskin.cs
- ClientTarget.cs
- ColorConverter.cs
- StatusBar.cs
- MultiPropertyDescriptorGridEntry.cs
- PropertyEmitterBase.cs
- WindowsRichEdit.cs
- BaseCAMarshaler.cs
- JoinGraph.cs
- StatusBarItemAutomationPeer.cs
- CheckedPointers.cs
- QueryConverter.cs
- BindingSource.cs
- QilUnary.cs
- Application.cs
- XamlReaderConstants.cs
- DebuggerAttributes.cs
- ChooseAction.cs
- ListenerServiceInstallComponent.cs
- ArithmeticException.cs
- BaseCollection.cs
- UnsafeNetInfoNativeMethods.cs
- DataGrid.cs