Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / EntitySetBaseCollection.cs / 1 / EntitySetBaseCollection.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
using System.Reflection;
using System.Text;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a collection of entity set objects
///
internal sealed class EntitySetBaseCollection : MetadataCollection
{
// This collection allows changes to be intercepted before and after they are passed to MetadataCollection. The interception
// is required to update the EntitySet's back-reference to the EntityContainer.
#region Constructors
///
/// Default constructor for constructing an empty collection
///
/// The entity container that has this entity set collection
/// Thrown if the argument entityContainer is null
internal EntitySetBaseCollection(EntityContainer entityContainer)
: this(entityContainer, null)
{
}
///
/// The constructor for constructing the collection with the given items
///
/// The entity container that has this entity set collection
/// The items to populate the collection
/// Thrown if the argument entityContainer is null
internal EntitySetBaseCollection(EntityContainer entityContainer, IEnumerable items)
: base(items)
{
EntityUtil.GenericCheckArgumentNull(entityContainer, "entityContainer");
_entityContainer = entityContainer;
}
#endregion
#region Fields
private readonly EntityContainer _entityContainer;
#endregion
#region Properties
///
/// Gets an item from the collection with the given index
///
/// The index to search for
/// An item from the collection
/// Thrown if the index is out of the range for the Collection
/// Always thrown on setter
public override EntitySetBase this[int index]
{
get
{
return base[index];
}
set
{
throw EntityUtil.OperationOnReadOnlyCollection();
}
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if the Collection does not have an EntitySet with the given identity
/// Always thrown on setter
public override EntitySetBase this[string identity]
{
get
{
return base[identity];
}
set
{
throw EntityUtil.OperationOnReadOnlyCollection();
}
}
#endregion
#region Methods
///
/// Adds an item to the collection
///
/// The item to add to the list
/// Thrown if item argument is null
/// Thrown if the item passed in or the collection itself instance is in ReadOnly state
/// Thrown if the EntitySetBase that is being added already belongs to another EntityContainer
/// Thrown if the EntitySetCollection already contains an EntitySet with the same identity
public override void Add(EntitySetBase item)
{
EntityUtil.GenericCheckArgumentNull(item, "item");
// Check to make sure the given entity set is not associated with another type
ThrowIfItHasEntityContainer(item, "item");
base.Add(item);
// Fix up the declaring type
item.ChangeEntityContainerWithoutCollectionFixup(_entityContainer);
}
///
/// Checks if the given entity set already has a entity container, if so, throw an exception
///
/// The entity set to check for
/// The name of the argument from the caller
private static void ThrowIfItHasEntityContainer(EntitySetBase entitySet, string argumentName)
{
EntityUtil.GenericCheckArgumentNull(entitySet, argumentName);
if (entitySet.EntityContainer != null)
{
throw EntityUtil.EntitySetInAnotherContainer(argumentName);
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
using System.Reflection;
using System.Text;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a collection of entity set objects
///
internal sealed class EntitySetBaseCollection : MetadataCollection
{
// This collection allows changes to be intercepted before and after they are passed to MetadataCollection. The interception
// is required to update the EntitySet's back-reference to the EntityContainer.
#region Constructors
///
/// Default constructor for constructing an empty collection
///
/// The entity container that has this entity set collection
/// Thrown if the argument entityContainer is null
internal EntitySetBaseCollection(EntityContainer entityContainer)
: this(entityContainer, null)
{
}
///
/// The constructor for constructing the collection with the given items
///
/// The entity container that has this entity set collection
/// The items to populate the collection
/// Thrown if the argument entityContainer is null
internal EntitySetBaseCollection(EntityContainer entityContainer, IEnumerable items)
: base(items)
{
EntityUtil.GenericCheckArgumentNull(entityContainer, "entityContainer");
_entityContainer = entityContainer;
}
#endregion
#region Fields
private readonly EntityContainer _entityContainer;
#endregion
#region Properties
///
/// Gets an item from the collection with the given index
///
/// The index to search for
/// An item from the collection
/// Thrown if the index is out of the range for the Collection
/// Always thrown on setter
public override EntitySetBase this[int index]
{
get
{
return base[index];
}
set
{
throw EntityUtil.OperationOnReadOnlyCollection();
}
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if the Collection does not have an EntitySet with the given identity
/// Always thrown on setter
public override EntitySetBase this[string identity]
{
get
{
return base[identity];
}
set
{
throw EntityUtil.OperationOnReadOnlyCollection();
}
}
#endregion
#region Methods
///
/// Adds an item to the collection
///
/// The item to add to the list
/// Thrown if item argument is null
/// Thrown if the item passed in or the collection itself instance is in ReadOnly state
/// Thrown if the EntitySetBase that is being added already belongs to another EntityContainer
/// Thrown if the EntitySetCollection already contains an EntitySet with the same identity
public override void Add(EntitySetBase item)
{
EntityUtil.GenericCheckArgumentNull(item, "item");
// Check to make sure the given entity set is not associated with another type
ThrowIfItHasEntityContainer(item, "item");
base.Add(item);
// Fix up the declaring type
item.ChangeEntityContainerWithoutCollectionFixup(_entityContainer);
}
///
/// Checks if the given entity set already has a entity container, if so, throw an exception
///
/// The entity set to check for
/// The name of the argument from the caller
private static void ThrowIfItHasEntityContainer(EntitySetBase entitySet, string argumentName)
{
EntityUtil.GenericCheckArgumentNull(entitySet, argumentName);
if (entitySet.EntityContainer != null)
{
throw EntityUtil.EntitySetInAnotherContainer(argumentName);
}
}
#endregion
}
}
// 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
- GridItemPatternIdentifiers.cs
- SmtpNtlmAuthenticationModule.cs
- ByteFacetDescriptionElement.cs
- SiteMapNodeItemEventArgs.cs
- TableItemPatternIdentifiers.cs
- DllNotFoundException.cs
- AsyncPostBackErrorEventArgs.cs
- DataGridViewMethods.cs
- BitmapFrameDecode.cs
- IOThreadScheduler.cs
- Effect.cs
- XmlSchemaAttributeGroup.cs
- SQLInt64.cs
- SnapLine.cs
- Misc.cs
- UriTemplateTableMatchCandidate.cs
- CookieProtection.cs
- DataFormats.cs
- DoubleUtil.cs
- UnionExpr.cs
- SkewTransform.cs
- AspNetSynchronizationContext.cs
- storagemappingitemcollection.viewdictionary.cs
- ContractValidationHelper.cs
- XmlQueryTypeFactory.cs
- WorkflowDesignerMessageFilter.cs
- HTMLTextWriter.cs
- MultiPropertyDescriptorGridEntry.cs
- MetadataArtifactLoaderResource.cs
- TextCharacters.cs
- String.cs
- TagMapCollection.cs
- Comparer.cs
- Comparer.cs
- Transform.cs
- StatusBarItemAutomationPeer.cs
- DbParameterCollection.cs
- RemoteWebConfigurationHost.cs
- HostExecutionContextManager.cs
- HTMLTextWriter.cs
- ScrollChangedEventArgs.cs
- AnnotationDocumentPaginator.cs
- Not.cs
- CheckBox.cs
- ToolBarPanel.cs
- GeneralEndpointIdentity.cs
- RecordsAffectedEventArgs.cs
- EmissiveMaterial.cs
- VectorAnimation.cs
- ClientUtils.cs
- ExpressionList.cs
- UshortList2.cs
- ToolStripItemClickedEventArgs.cs
- TypeBuilder.cs
- TextEditorParagraphs.cs
- SafeLibraryHandle.cs
- XmlArrayItemAttribute.cs
- PrimitiveType.cs
- BrowserCapabilitiesFactoryBase.cs
- FacetDescription.cs
- PrefixHandle.cs
- PeerContact.cs
- MobileControlsSectionHelper.cs
- IxmlLineInfo.cs
- CursorConverter.cs
- ColumnResult.cs
- GridSplitterAutomationPeer.cs
- DurableInstance.cs
- StorageMappingItemCollection.cs
- PrintPreviewDialog.cs
- EventHandlers.cs
- PackageRelationshipSelector.cs
- UInt16Converter.cs
- Border.cs
- CodeArrayCreateExpression.cs
- WindowsAuthenticationEventArgs.cs
- sqlnorm.cs
- TextEndOfSegment.cs
- DataGridViewDataConnection.cs
- UnsafeNetInfoNativeMethods.cs
- Relationship.cs
- InputScopeNameConverter.cs
- OleDbSchemaGuid.cs
- PerformanceCounterLib.cs
- Row.cs
- MenuCommand.cs
- recordstatefactory.cs
- DataGridColumnHeaderCollection.cs
- TaiwanLunisolarCalendar.cs
- ExclusiveHandleList.cs
- EventDrivenDesigner.cs
- ReadOnlyDictionary.cs
- XamlToRtfWriter.cs
- keycontainerpermission.cs
- PersonalizableAttribute.cs
- PeerEndPoint.cs
- ComponentRenameEvent.cs
- PathFigureCollection.cs
- ProfilePropertySettings.cs
- UnsafeNativeMethods.cs