Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / ItemType.cs / 2 / ItemType.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Data;
using System.Diagnostics;
using metadata = System.Data.Metadata.Edm;
using System.Data.Metadata.Edm;
namespace System.Data.EntityModel.SchemaObjectModel
{
///
/// Summary description for Item.
///
[System.Diagnostics.DebuggerDisplay("Name={Name}, BaseType={BaseType.FQName}, HasKeys={HasKeys}")]
internal sealed class SchemaEntityType : StructuredType
{
#region Private Fields
private const char KEY_DELIMITER = ' ';
private ISchemaElementLookUpTable _navigationProperties = null;
private EntityKeyElement _keyElement = null;
private static List EmptyKeyProperties = new List(0);
#endregion
#region Public Methods
///
///
///
///
public SchemaEntityType(Schema parentElement)
: base(parentElement)
{
}
#endregion
#region Protected Methods
///
///
///
internal override void ResolveTopLevelNames()
{
base.ResolveTopLevelNames();
if (BaseType != null)
{
if (!(BaseType is SchemaEntityType))
{
AddError(ErrorCode.InvalidBaseType, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.InvalidBaseTypeForItemType(BaseType.FQName, FQName));
}
// Since the base type is not null, key must be defined on the base type
else if (_keyElement != null && BaseType != null)
{
AddError(ErrorCode.InvalidKey, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.InvalidKeyKeyDefinedInBaseClass(FQName, BaseType.FQName));
}
}
// If the base type is not null, then the key must be defined on the base entity type, since
// we don't allow entity type without keys.
else if (_keyElement == null)
{
AddError(ErrorCode.KeyMissingOnEntityType, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.KeyMissingOnEntityType(this.FQName));
}
else if (null == BaseType && null != UnresolvedBaseType)
{
// this is already an error situation, we won't do any resolve name further in this type
return;
}
else
{
_keyElement.ResolveTopLevelNames();
}
}
#endregion
#region Protected Properties
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
return false;
}
#endregion
#region Private Methods
#endregion
#region Public Properties
public EntityKeyElement KeyElement
{
get
{
return _keyElement;
}
}
///
///
///
public IList DeclaredKeyProperties
{
get
{
if (KeyElement == null)
{
return EmptyKeyProperties;
}
return KeyElement.KeyProperties;
}
}
///
///
///
///
public IList KeyProperties
{
get
{
if (KeyElement == null)
{
if (BaseType != null)
{
System.Diagnostics.Debug.Assert(BaseType is SchemaEntityType, "ItemType.BaseType is not ItemType");
return (BaseType as SchemaEntityType).KeyProperties;
}
return EmptyKeyProperties;
}
return this.KeyElement.KeyProperties;
}
}
///
///
///
public ISchemaElementLookUpTable NavigationProperties
{
get
{
if (_navigationProperties == null)
{
_navigationProperties = new FilteredSchemaElementLookUpTable(NamedMembers);
}
return _navigationProperties;
}
}
#endregion
#region Protected Methods
///
///
///
internal override void Validate()
{
// structured type base class will validate all members (properties, nav props, etc)
base.Validate();
if (this.KeyElement != null)
{
this.KeyElement.Validate();
}
}
#endregion
#region Protected Properties
protected override bool HandleElement(XmlReader reader)
{
if (base.HandleElement(reader))
{
return true;
}
else if (CanHandleElement(reader, XmlConstants.Key))
{
HandleKeyElement(reader);
return true;
}
else if (CanHandleElement(reader, XmlConstants.NavigationProperty))
{
HandleNavigationPropertyElement(reader);
return true;
}
return false;
}
#endregion
#region Private Methods
///
///
///
///
private void HandleNavigationPropertyElement(XmlReader reader)
{
NavigationProperty navigationProperty = new NavigationProperty(this);
navigationProperty.Parse(reader);
AddMember(navigationProperty);
}
///
///
///
///
private void HandleKeyElement(XmlReader reader)
{
_keyElement = new EntityKeyElement(this);
_keyElement.Parse(reader);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Data;
using System.Diagnostics;
using metadata = System.Data.Metadata.Edm;
using System.Data.Metadata.Edm;
namespace System.Data.EntityModel.SchemaObjectModel
{
///
/// Summary description for Item.
///
[System.Diagnostics.DebuggerDisplay("Name={Name}, BaseType={BaseType.FQName}, HasKeys={HasKeys}")]
internal sealed class SchemaEntityType : StructuredType
{
#region Private Fields
private const char KEY_DELIMITER = ' ';
private ISchemaElementLookUpTable _navigationProperties = null;
private EntityKeyElement _keyElement = null;
private static List EmptyKeyProperties = new List(0);
#endregion
#region Public Methods
///
///
///
///
public SchemaEntityType(Schema parentElement)
: base(parentElement)
{
}
#endregion
#region Protected Methods
///
///
///
internal override void ResolveTopLevelNames()
{
base.ResolveTopLevelNames();
if (BaseType != null)
{
if (!(BaseType is SchemaEntityType))
{
AddError(ErrorCode.InvalidBaseType, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.InvalidBaseTypeForItemType(BaseType.FQName, FQName));
}
// Since the base type is not null, key must be defined on the base type
else if (_keyElement != null && BaseType != null)
{
AddError(ErrorCode.InvalidKey, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.InvalidKeyKeyDefinedInBaseClass(FQName, BaseType.FQName));
}
}
// If the base type is not null, then the key must be defined on the base entity type, since
// we don't allow entity type without keys.
else if (_keyElement == null)
{
AddError(ErrorCode.KeyMissingOnEntityType, EdmSchemaErrorSeverity.Error,
System.Data.Entity.Strings.KeyMissingOnEntityType(this.FQName));
}
else if (null == BaseType && null != UnresolvedBaseType)
{
// this is already an error situation, we won't do any resolve name further in this type
return;
}
else
{
_keyElement.ResolveTopLevelNames();
}
}
#endregion
#region Protected Properties
protected override bool HandleAttribute(XmlReader reader)
{
if (base.HandleAttribute(reader))
{
return true;
}
return false;
}
#endregion
#region Private Methods
#endregion
#region Public Properties
public EntityKeyElement KeyElement
{
get
{
return _keyElement;
}
}
///
///
///
public IList DeclaredKeyProperties
{
get
{
if (KeyElement == null)
{
return EmptyKeyProperties;
}
return KeyElement.KeyProperties;
}
}
///
///
///
///
public IList KeyProperties
{
get
{
if (KeyElement == null)
{
if (BaseType != null)
{
System.Diagnostics.Debug.Assert(BaseType is SchemaEntityType, "ItemType.BaseType is not ItemType");
return (BaseType as SchemaEntityType).KeyProperties;
}
return EmptyKeyProperties;
}
return this.KeyElement.KeyProperties;
}
}
///
///
///
public ISchemaElementLookUpTable NavigationProperties
{
get
{
if (_navigationProperties == null)
{
_navigationProperties = new FilteredSchemaElementLookUpTable(NamedMembers);
}
return _navigationProperties;
}
}
#endregion
#region Protected Methods
///
///
///
internal override void Validate()
{
// structured type base class will validate all members (properties, nav props, etc)
base.Validate();
if (this.KeyElement != null)
{
this.KeyElement.Validate();
}
}
#endregion
#region Protected Properties
protected override bool HandleElement(XmlReader reader)
{
if (base.HandleElement(reader))
{
return true;
}
else if (CanHandleElement(reader, XmlConstants.Key))
{
HandleKeyElement(reader);
return true;
}
else if (CanHandleElement(reader, XmlConstants.NavigationProperty))
{
HandleNavigationPropertyElement(reader);
return true;
}
return false;
}
#endregion
#region Private Methods
///
///
///
///
private void HandleNavigationPropertyElement(XmlReader reader)
{
NavigationProperty navigationProperty = new NavigationProperty(this);
navigationProperty.Parse(reader);
AddMember(navigationProperty);
}
///
///
///
///
private void HandleKeyElement(XmlReader reader)
{
_keyElement = new EntityKeyElement(this);
_keyElement.Parse(reader);
}
#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
- Bind.cs
- TextDocumentView.cs
- DataGridViewRowsAddedEventArgs.cs
- Condition.cs
- ToolStripLabel.cs
- EventLogEntry.cs
- ProfileSection.cs
- CombinedGeometry.cs
- Opcode.cs
- SettingsAttributeDictionary.cs
- SqlLiftWhereClauses.cs
- Models.cs
- EventHandlerList.cs
- TransactionContext.cs
- DesignerForm.cs
- MessageDecoder.cs
- SmtpFailedRecipientsException.cs
- ImageMap.cs
- BindingParameterCollection.cs
- MappingException.cs
- Overlapped.cs
- FileDialog_Vista.cs
- CacheDict.cs
- UpdateDelegates.Generated.cs
- CryptoKeySecurity.cs
- glyphs.cs
- ResXResourceSet.cs
- ConfigurationLockCollection.cs
- ConfigurationPropertyCollection.cs
- KeyedHashAlgorithm.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- XamlTypeMapper.cs
- OleAutBinder.cs
- CodeDOMProvider.cs
- InkCanvasSelection.cs
- BuildProviderAppliesToAttribute.cs
- RuntimeHandles.cs
- DesignerActionPanel.cs
- IImplicitResourceProvider.cs
- GPPOINTF.cs
- DiscoveryEndpoint.cs
- WebBrowser.cs
- StoreAnnotationsMap.cs
- CodeTypeDeclaration.cs
- StatusBar.cs
- HttpListenerRequest.cs
- ArrayHelper.cs
- DateRangeEvent.cs
- SQLRoleProvider.cs
- SqlBulkCopyColumnMapping.cs
- SessionStateItemCollection.cs
- Color.cs
- ThreadStateException.cs
- XNameConverter.cs
- Rule.cs
- SetIndexBinder.cs
- TypeDescriptionProvider.cs
- PointAnimation.cs
- DirectoryNotFoundException.cs
- AstTree.cs
- AudioException.cs
- DragDropHelper.cs
- DbProviderConfigurationHandler.cs
- MetaModel.cs
- configsystem.cs
- ColorConvertedBitmap.cs
- DocumentSequenceHighlightLayer.cs
- PointLightBase.cs
- TextEditorCopyPaste.cs
- GenericNameHandler.cs
- WaitHandleCannotBeOpenedException.cs
- FramingDecoders.cs
- StringFunctions.cs
- WaitHandle.cs
- PermissionListSet.cs
- ElementsClipboardData.cs
- Adorner.cs
- ToolStripDropDown.cs
- WsdlInspector.cs
- DecimalStorage.cs
- DataIdProcessor.cs
- ManagedIStream.cs
- DetailsViewUpdateEventArgs.cs
- InternalDispatchObject.cs
- FileSystemEventArgs.cs
- QilPatternFactory.cs
- XmlValidatingReader.cs
- Style.cs
- DataShape.cs
- DbDataSourceEnumerator.cs
- Wizard.cs
- XNodeNavigator.cs
- DocumentPageHost.cs
- XpsSerializationManagerAsync.cs
- SHA256.cs
- RenderDataDrawingContext.cs
- SQLConvert.cs
- ReferenceEqualityComparer.cs
- ItemsChangedEventArgs.cs
- ShapingEngine.cs