Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / EntityContainerAssociationSetEnd.cs / 3 / EntityContainerAssociationSetEnd.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an element. /// internal sealed class EntityContainerAssociationSetEnd : EntityContainerRelationshipSetEnd { private string _unresolvedRelationshipEndRole; ////// Constructs an EntityContainerAssociationSetEnd /// /// Reference to the schema element. public EntityContainerAssociationSetEnd( EntityContainerAssociationSet parentElement ) : base( parentElement ) { } public string Role { get { return _unresolvedRelationshipEndRole; } set { _unresolvedRelationshipEndRole = value; } } public override string Name { get { return Role; } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Role)) { HandleRoleAttribute(reader); return true; } return false; } ////// This is the method that is called when an Role Attribute is encountered. /// /// The XmlRead positned at the extent attribute. private void HandleRoleAttribute( XmlReader reader ) { _unresolvedRelationshipEndRole = HandleUndottedNameAttribute( reader, _unresolvedRelationshipEndRole ); } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); // resolve end name to the corosponding relationship end IRelationship relationship = ParentElement.Relationship; if ( relationship == null ) { // error already logged for this return; } } internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); if (_unresolvedRelationshipEndRole == null && EntitySet != null) { // no role provided, infer it RelationshipEnd = InferRelationshipEnd(EntitySet); if (RelationshipEnd != null) { _unresolvedRelationshipEndRole = RelationshipEnd.Name; } } else if (_unresolvedRelationshipEndRole != null) { IRelationship relationship = ParentElement.Relationship; IRelationshipEnd end; if (relationship.TryGetEnd(_unresolvedRelationshipEndRole, out end)) { RelationshipEnd = end; } else { // couldn't find a matching relationship end for this RelationshipSet end AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEntityEndName(Role, relationship.FQName)); } } } ////// If the role name is missing but an entity set is given, figure out what the /// relationship end should be /// /// The given EntitySet ///The appropriate relationship end private IRelationshipEnd InferRelationshipEnd( EntityContainerEntitySet set ) { Debug.Assert(set != null, "set parameter is null"); if ( ParentElement.Relationship == null ) { return null; } ListpossibleEnds = new List (); foreach ( IRelationshipEnd end in ParentElement.Relationship.Ends ) { if ( set.EntityType.IsOfType( end.Type ) ) { possibleEnds.Add( end ); } } if ( possibleEnds.Count == 1 ) { return possibleEnds[0]; } else if ( possibleEnds.Count == 0 ) { // no matchs AddError( ErrorCode.FailedInference, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndFailedNoEntitySetMatch( set.FQName, this.ParentElement.FQName, ParentElement.Relationship.FQName, set.EntityType.FQName, this.ParentElement.ParentElement.FQName ) ); } else { // ambigous AddError( ErrorCode.FailedInference, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndAmbigous( set.FQName, this.ParentElement.FQName, ParentElement.Relationship.FQName, set.EntityType.FQName, this.ParentElement.ParentElement.FQName)); } return null; } internal override SchemaElement Clone(SchemaElement parentElement) { EntityContainerAssociationSetEnd setEnd = new EntityContainerAssociationSetEnd((EntityContainerAssociationSet)parentElement); setEnd._unresolvedRelationshipEndRole = _unresolvedRelationshipEndRole; setEnd.EntitySet = this.EntitySet; return setEnd; } } } // 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.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an element. /// internal sealed class EntityContainerAssociationSetEnd : EntityContainerRelationshipSetEnd { private string _unresolvedRelationshipEndRole; ////// Constructs an EntityContainerAssociationSetEnd /// /// Reference to the schema element. public EntityContainerAssociationSetEnd( EntityContainerAssociationSet parentElement ) : base( parentElement ) { } public string Role { get { return _unresolvedRelationshipEndRole; } set { _unresolvedRelationshipEndRole = value; } } public override string Name { get { return Role; } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Role)) { HandleRoleAttribute(reader); return true; } return false; } ////// This is the method that is called when an Role Attribute is encountered. /// /// The XmlRead positned at the extent attribute. private void HandleRoleAttribute( XmlReader reader ) { _unresolvedRelationshipEndRole = HandleUndottedNameAttribute( reader, _unresolvedRelationshipEndRole ); } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); // resolve end name to the corosponding relationship end IRelationship relationship = ParentElement.Relationship; if ( relationship == null ) { // error already logged for this return; } } internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); if (_unresolvedRelationshipEndRole == null && EntitySet != null) { // no role provided, infer it RelationshipEnd = InferRelationshipEnd(EntitySet); if (RelationshipEnd != null) { _unresolvedRelationshipEndRole = RelationshipEnd.Name; } } else if (_unresolvedRelationshipEndRole != null) { IRelationship relationship = ParentElement.Relationship; IRelationshipEnd end; if (relationship.TryGetEnd(_unresolvedRelationshipEndRole, out end)) { RelationshipEnd = end; } else { // couldn't find a matching relationship end for this RelationshipSet end AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEntityEndName(Role, relationship.FQName)); } } } ////// If the role name is missing but an entity set is given, figure out what the /// relationship end should be /// /// The given EntitySet ///The appropriate relationship end private IRelationshipEnd InferRelationshipEnd( EntityContainerEntitySet set ) { Debug.Assert(set != null, "set parameter is null"); if ( ParentElement.Relationship == null ) { return null; } ListpossibleEnds = new List (); foreach ( IRelationshipEnd end in ParentElement.Relationship.Ends ) { if ( set.EntityType.IsOfType( end.Type ) ) { possibleEnds.Add( end ); } } if ( possibleEnds.Count == 1 ) { return possibleEnds[0]; } else if ( possibleEnds.Count == 0 ) { // no matchs AddError( ErrorCode.FailedInference, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndFailedNoEntitySetMatch( set.FQName, this.ParentElement.FQName, ParentElement.Relationship.FQName, set.EntityType.FQName, this.ParentElement.ParentElement.FQName ) ); } else { // ambigous AddError( ErrorCode.FailedInference, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndAmbigous( set.FQName, this.ParentElement.FQName, ParentElement.Relationship.FQName, set.EntityType.FQName, this.ParentElement.ParentElement.FQName)); } return null; } internal override SchemaElement Clone(SchemaElement parentElement) { EntityContainerAssociationSetEnd setEnd = new EntityContainerAssociationSetEnd((EntityContainerAssociationSet)parentElement); setEnd._unresolvedRelationshipEndRole = _unresolvedRelationshipEndRole; setEnd.EntitySet = this.EntitySet; return setEnd; } } } // 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
- EdgeProfileValidation.cs
- TableCellCollection.cs
- ListViewSelectEventArgs.cs
- ValueTable.cs
- dsa.cs
- BitmapMetadataEnumerator.cs
- Thickness.cs
- CodeTypeOfExpression.cs
- FreeFormDesigner.cs
- TextTreeExtractElementUndoUnit.cs
- HostingEnvironmentWrapper.cs
- Mappings.cs
- StatusBar.cs
- BufferedGraphicsManager.cs
- StringReader.cs
- MethodImplAttribute.cs
- FormsAuthenticationTicket.cs
- LabelLiteral.cs
- EndpointDiscoveryBehavior.cs
- Configuration.cs
- DocumentAutomationPeer.cs
- TypefaceMetricsCache.cs
- ReachDocumentReferenceCollectionSerializerAsync.cs
- LoggedException.cs
- HostedBindingBehavior.cs
- CodeCommentStatement.cs
- FrameworkRichTextComposition.cs
- CfgParser.cs
- ScrollableControl.cs
- WizardPanel.cs
- DataGridViewTextBoxColumn.cs
- AlphabeticalEnumConverter.cs
- DirectoryNotFoundException.cs
- TimeoutException.cs
- path.cs
- WorkflowInstanceContextProvider.cs
- ThemeableAttribute.cs
- WindowPattern.cs
- XmlSignificantWhitespace.cs
- XmlChildEnumerator.cs
- ToolStripItemTextRenderEventArgs.cs
- DefinitionBase.cs
- validation.cs
- WorkItem.cs
- ThousandthOfEmRealDoubles.cs
- ScriptControlDescriptor.cs
- DataGridColumn.cs
- Matrix3DValueSerializer.cs
- CompilationRelaxations.cs
- ErrorActivity.cs
- SplineKeyFrames.cs
- ArrayConverter.cs
- XmlAtomicValue.cs
- StringAnimationBase.cs
- RelationshipConverter.cs
- StringComparer.cs
- FixedSOMPageElement.cs
- StickyNoteAnnotations.cs
- Path.cs
- TableCellCollection.cs
- SplineKeyFrames.cs
- LayoutTable.cs
- ChangeInterceptorAttribute.cs
- AuthenticationException.cs
- DataObject.cs
- PageAsyncTaskManager.cs
- WebPartConnectVerb.cs
- VisualBrush.cs
- X509ChainPolicy.cs
- SoapIgnoreAttribute.cs
- AssemblyAttributes.cs
- ScrollableControlDesigner.cs
- TrackingProfile.cs
- PLINQETWProvider.cs
- FormatSettings.cs
- XmlTextReader.cs
- DataGridViewCellLinkedList.cs
- UserNamePasswordValidator.cs
- OutputScope.cs
- WebPartManager.cs
- ChangeProcessor.cs
- SetMemberBinder.cs
- MultiView.cs
- ChangeNode.cs
- XmlILStorageConverter.cs
- ContentValidator.cs
- Table.cs
- ListenerConfig.cs
- ReachDocumentReferenceCollectionSerializer.cs
- HttpConfigurationSystem.cs
- httpapplicationstate.cs
- NavigationWindowAutomationPeer.cs
- MediaEntryAttribute.cs
- NamespaceQuery.cs
- TypeConverterAttribute.cs
- XmlIgnoreAttribute.cs
- FixedSOMSemanticBox.cs
- MembershipUser.cs
- HttpProcessUtility.cs
- TypeSystem.cs