Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / EntityContainer.cs / 3 / EntityContainer.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// Class for representing an entity container
///
public sealed class EntityContainer : GlobalItem
{
#region Constructors
///
/// The constructor for constructing the EntityContainer object with the name, namespaceName, and version.
///
/// The name of this entity container
/// dataSpace in which this entity container belongs to
/// Thrown if the name argument is null
/// Thrown if the name argument is empty string
internal EntityContainer(string name, DataSpace dataSpace)
{
EntityUtil.CheckStringArgument(name, "name");
_name = name;
this.DataSpace = dataSpace;
_baseEntitySets = new ReadOnlyMetadataCollection(new EntitySetBaseCollection(this));
_functionImports = new ReadOnlyMetadataCollection(new MetadataCollection());
}
#endregion
#region Fields
private readonly string _name;
private readonly ReadOnlyMetadataCollection _baseEntitySets;
private readonly ReadOnlyMetadataCollection _functionImports;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.EntityContainer; } }
///
/// Gets the identity for this item as a string
///
internal override string Identity
{
get
{
return this.Name;
}
}
///
/// Get the name of this EntityContainer object
///
[MetadataProperty(PrimitiveTypeKind.String, false)]
public String Name
{
get
{
return _name;
}
}
///
/// Gets the collection of entity sets
///
[MetadataProperty(BuiltInTypeKind.EntitySetBase, true)]
public ReadOnlyMetadataCollection BaseEntitySets
{
get
{
return _baseEntitySets;
}
}
///
/// Gets the collection of function imports for this entity container
///
[MetadataProperty(BuiltInTypeKind.EdmFunction, true)]
internal ReadOnlyMetadataCollection FunctionImports
{
get
{
return _functionImports;
}
}
#endregion
#region Methods
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
this.BaseEntitySets.Source.SetReadOnly();
this.FunctionImports.Source.SetReadOnly();
}
}
///
/// Get the entity set with the given name
///
/// name of the entity set to look up for
/// true if you want to do a case-insensitive lookup
///
public EntitySet GetEntitySetByName(string name, bool ignoreCase)
{
EntitySet entitySet = (BaseEntitySets.GetValue(name, ignoreCase) as EntitySet);
if (null != entitySet)
{
return entitySet;
}
throw EntityUtil.InvalidEntitySetName(name);
}
///
/// Get the entity set with the given name or return null if not found
///
/// name of the entity set to look up for
/// true if you want to do a case-insensitive lookup
/// out parameter that will contain the result
///
/// if name argument is null
public bool TryGetEntitySetByName(string name, bool ignoreCase, out EntitySet entitySet)
{
EntityUtil.CheckArgumentNull(name, "name");
EntitySetBase baseEntitySet = null;
entitySet = null;
if (this.BaseEntitySets.TryGetValue(name, ignoreCase, out baseEntitySet))
{
if (Helper.IsEntitySet(baseEntitySet))
{
entitySet = (EntitySet)baseEntitySet;
return true;
}
}
return false;
}
///
/// Get the relationship set with the given name
///
/// name of the relationship set to look up for
/// true if you want to do a case-insensitive lookup
///
public RelationshipSet GetRelationshipSetByName(string name, bool ignoreCase)
{
RelationshipSet relationshipSet;
if (!this.TryGetRelationshipSetByName(name, ignoreCase, out relationshipSet))
{
throw EntityUtil.InvalidRelationshipSetName(name);
}
return relationshipSet;
}
///
/// Get the relationship set with the given name
///
/// name of the relationship set to look up for
/// true if you want to do a case-insensitive lookup
/// out parameter that will have the result
///
/// if name argument is null
public bool TryGetRelationshipSetByName(string name, bool ignoreCase, out RelationshipSet relationshipSet)
{
EntityUtil.CheckArgumentNull(name, "name");
EntitySetBase baseEntitySet = null;
relationshipSet = null;
if (this.BaseEntitySets.TryGetValue(name, ignoreCase, out baseEntitySet))
{
if (Helper.IsRelationshipSet(baseEntitySet))
{
relationshipSet = (RelationshipSet)baseEntitySet;
return true;
}
}
return false;
}
///
/// Overriding System.Object.ToString to provide better String representation
/// for this type.
///
public override string ToString()
{
return Name;
}
internal void AddEntitySetBase(EntitySetBase entitySetBase)
{
_baseEntitySets.Source.Add(entitySetBase);
}
internal void AddFunctionImport(EdmFunction function)
{
Debug.Assert(null != function);
_functionImports.Source.Add(function);
}
#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.Generic;
using System.Data.Common;
using System.Text;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// Class for representing an entity container
///
public sealed class EntityContainer : GlobalItem
{
#region Constructors
///
/// The constructor for constructing the EntityContainer object with the name, namespaceName, and version.
///
/// The name of this entity container
/// dataSpace in which this entity container belongs to
/// Thrown if the name argument is null
/// Thrown if the name argument is empty string
internal EntityContainer(string name, DataSpace dataSpace)
{
EntityUtil.CheckStringArgument(name, "name");
_name = name;
this.DataSpace = dataSpace;
_baseEntitySets = new ReadOnlyMetadataCollection(new EntitySetBaseCollection(this));
_functionImports = new ReadOnlyMetadataCollection(new MetadataCollection());
}
#endregion
#region Fields
private readonly string _name;
private readonly ReadOnlyMetadataCollection _baseEntitySets;
private readonly ReadOnlyMetadataCollection _functionImports;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.EntityContainer; } }
///
/// Gets the identity for this item as a string
///
internal override string Identity
{
get
{
return this.Name;
}
}
///
/// Get the name of this EntityContainer object
///
[MetadataProperty(PrimitiveTypeKind.String, false)]
public String Name
{
get
{
return _name;
}
}
///
/// Gets the collection of entity sets
///
[MetadataProperty(BuiltInTypeKind.EntitySetBase, true)]
public ReadOnlyMetadataCollection BaseEntitySets
{
get
{
return _baseEntitySets;
}
}
///
/// Gets the collection of function imports for this entity container
///
[MetadataProperty(BuiltInTypeKind.EdmFunction, true)]
internal ReadOnlyMetadataCollection FunctionImports
{
get
{
return _functionImports;
}
}
#endregion
#region Methods
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
this.BaseEntitySets.Source.SetReadOnly();
this.FunctionImports.Source.SetReadOnly();
}
}
///
/// Get the entity set with the given name
///
/// name of the entity set to look up for
/// true if you want to do a case-insensitive lookup
///
public EntitySet GetEntitySetByName(string name, bool ignoreCase)
{
EntitySet entitySet = (BaseEntitySets.GetValue(name, ignoreCase) as EntitySet);
if (null != entitySet)
{
return entitySet;
}
throw EntityUtil.InvalidEntitySetName(name);
}
///
/// Get the entity set with the given name or return null if not found
///
/// name of the entity set to look up for
/// true if you want to do a case-insensitive lookup
/// out parameter that will contain the result
///
/// if name argument is null
public bool TryGetEntitySetByName(string name, bool ignoreCase, out EntitySet entitySet)
{
EntityUtil.CheckArgumentNull(name, "name");
EntitySetBase baseEntitySet = null;
entitySet = null;
if (this.BaseEntitySets.TryGetValue(name, ignoreCase, out baseEntitySet))
{
if (Helper.IsEntitySet(baseEntitySet))
{
entitySet = (EntitySet)baseEntitySet;
return true;
}
}
return false;
}
///
/// Get the relationship set with the given name
///
/// name of the relationship set to look up for
/// true if you want to do a case-insensitive lookup
///
public RelationshipSet GetRelationshipSetByName(string name, bool ignoreCase)
{
RelationshipSet relationshipSet;
if (!this.TryGetRelationshipSetByName(name, ignoreCase, out relationshipSet))
{
throw EntityUtil.InvalidRelationshipSetName(name);
}
return relationshipSet;
}
///
/// Get the relationship set with the given name
///
/// name of the relationship set to look up for
/// true if you want to do a case-insensitive lookup
/// out parameter that will have the result
///
/// if name argument is null
public bool TryGetRelationshipSetByName(string name, bool ignoreCase, out RelationshipSet relationshipSet)
{
EntityUtil.CheckArgumentNull(name, "name");
EntitySetBase baseEntitySet = null;
relationshipSet = null;
if (this.BaseEntitySets.TryGetValue(name, ignoreCase, out baseEntitySet))
{
if (Helper.IsRelationshipSet(baseEntitySet))
{
relationshipSet = (RelationshipSet)baseEntitySet;
return true;
}
}
return false;
}
///
/// Overriding System.Object.ToString to provide better String representation
/// for this type.
///
public override string ToString()
{
return Name;
}
internal void AddEntitySetBase(EntitySetBase entitySetBase)
{
_baseEntitySets.Source.Add(entitySetBase);
}
internal void AddFunctionImport(EdmFunction function)
{
Debug.Assert(null != function);
_functionImports.Source.Add(function);
}
#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
- SqlPersistenceWorkflowInstanceDescription.cs
- SortableBindingList.cs
- MetadataProperty.cs
- HttpProcessUtility.cs
- CheckBoxBaseAdapter.cs
- CallbackException.cs
- RangeValueProviderWrapper.cs
- NativeMethods.cs
- WorkflowInstanceSuspendedRecord.cs
- DbTransaction.cs
- PrintDialog.cs
- BamlBinaryWriter.cs
- XmlSchemaCompilationSettings.cs
- DynamicMethod.cs
- FileRecordSequenceCompletedAsyncResult.cs
- CreateUserWizard.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- MarkupObject.cs
- Int32EqualityComparer.cs
- WebProxyScriptElement.cs
- StructuredTypeEmitter.cs
- XmlSchemaAttributeGroup.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- AppManager.cs
- ELinqQueryState.cs
- ITreeGenerator.cs
- InternalBufferOverflowException.cs
- FontSourceCollection.cs
- EllipseGeometry.cs
- ValueProviderWrapper.cs
- DispatcherFrame.cs
- SmtpDateTime.cs
- WorkflowDefinitionDispenser.cs
- XmlSchemaAnnotation.cs
- InvalidCastException.cs
- CallTemplateAction.cs
- TraceEventCache.cs
- EventLogEntryCollection.cs
- IsolatedStorageFilePermission.cs
- OpenTypeLayoutCache.cs
- ToolstripProfessionalRenderer.cs
- KeyValueSerializer.cs
- DataReceivedEventArgs.cs
- CLRBindingWorker.cs
- WindowsMenu.cs
- VerificationAttribute.cs
- DbConnectionOptions.cs
- VBIdentifierNameEditor.cs
- UserControlBuildProvider.cs
- BehaviorEditorPart.cs
- DataGridViewButtonColumn.cs
- TemplateControlCodeDomTreeGenerator.cs
- CompositeDataBoundControl.cs
- CodeGenerator.cs
- ProfileParameter.cs
- ThicknessKeyFrameCollection.cs
- WorkflowInstanceTerminatedRecord.cs
- Attributes.cs
- AssemblyNameUtility.cs
- SQLInt64.cs
- AudioFormatConverter.cs
- EntityDataSourceSelectingEventArgs.cs
- FormatSelectingMessageInspector.cs
- WindowsToolbarAsMenu.cs
- Simplifier.cs
- ServiceChannel.cs
- LinqDataSourceInsertEventArgs.cs
- UserPreferenceChangedEventArgs.cs
- BitmapEffectGroup.cs
- PanelStyle.cs
- SafeLibraryHandle.cs
- SubMenuStyle.cs
- DataSourceControlBuilder.cs
- WebChannelFactory.cs
- IdentityNotMappedException.cs
- TraceContextRecord.cs
- SynchronizedDispatch.cs
- SQLString.cs
- SizeValueSerializer.cs
- PeerName.cs
- DataGridViewComboBoxColumn.cs
- RuleRef.cs
- ScaleTransform3D.cs
- precedingquery.cs
- RichTextBox.cs
- EntityDataSourceDataSelectionPanel.cs
- _AutoWebProxyScriptWrapper.cs
- D3DImage.cs
- ColorMatrix.cs
- ServiceAppDomainAssociationProvider.cs
- GenericEnumerator.cs
- XmlWrappingWriter.cs
- DetailsViewRowCollection.cs
- InputScope.cs
- GPPOINT.cs
- DefaultDiscoveryServiceExtension.cs
- EventLogConfiguration.cs
- HttpCachePolicyElement.cs
- Application.cs
- ListBoxAutomationPeer.cs