Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / ReferentialConstraintRoleElement.cs / 1305376 / ReferentialConstraintRoleElement.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 role element in referential constraint element. /// internal sealed class ReferentialConstraintRoleElement : SchemaElement { private List_roleProperties; private IRelationshipEnd _end; /// /// Constructs an EntityContainerAssociationSetEnd /// /// Reference to the schema element. public ReferentialConstraintRoleElement(ReferentialConstraint parentElement) : base( parentElement ) { } public IListRoleProperties { get { if (_roleProperties == null) { _roleProperties = new List (); } return _roleProperties; } } public IRelationshipEnd End { get { return _end; } } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.PropertyRef)) { HandlePropertyRefElement(reader); return true; } return false; } protected override bool HandleAttribute(XmlReader reader) { if (CanHandleAttribute(reader, XmlConstants.Role)) { HandleRoleAttribute(reader); return true; } return false; } /// /// /// /// private void HandlePropertyRefElement(XmlReader reader) { PropertyRefElement property = new PropertyRefElement(ParentElement); property.Parse(reader); this.RoleProperties.Add(property); } private void HandleRoleAttribute(XmlReader reader) { string roleName; Utils.GetString(Schema, reader, out roleName); this.Name = roleName; } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { Debug.Assert(!String.IsNullOrEmpty(this.Name), "RoleName should never be empty"); IRelationship relationship = (IRelationship)this.ParentElement.ParentElement; if (!relationship.TryGetEnd(this.Name, out _end)) { AddError(ErrorCode.InvalidRoleInRelationshipConstraint, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEndRoleInRelationshipConstraint(this.Name, relationship.Name)); return; } // we are gauranteed that the _end has gone through ResolveNames, but // we are not gauranteed that it was successful if (_end.Type == null) { // an error has already been added for this return; } } internal override void Validate() { base.Validate(); // we can't resolve these names until validate because they will reference properties and types // that may not be resolved when this objects ResolveNames gets called Debug.Assert(_roleProperties != null, "xsd should have verified that there should be atleast one property ref element in referential role element"); foreach (PropertyRefElement property in _roleProperties) { if (!property.ResolveNames((SchemaEntityType)_end.Type)) { AddError(ErrorCode.InvalidPropertyInRelationshipConstraint, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidPropertyInRelationshipConstraint( property.Name, this.Name)); } } } } } // 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 role element in referential constraint element. /// internal sealed class ReferentialConstraintRoleElement : SchemaElement { private List_roleProperties; private IRelationshipEnd _end; /// /// Constructs an EntityContainerAssociationSetEnd /// /// Reference to the schema element. public ReferentialConstraintRoleElement(ReferentialConstraint parentElement) : base( parentElement ) { } public IListRoleProperties { get { if (_roleProperties == null) { _roleProperties = new List (); } return _roleProperties; } } public IRelationshipEnd End { get { return _end; } } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.PropertyRef)) { HandlePropertyRefElement(reader); return true; } return false; } protected override bool HandleAttribute(XmlReader reader) { if (CanHandleAttribute(reader, XmlConstants.Role)) { HandleRoleAttribute(reader); return true; } return false; } /// /// /// /// private void HandlePropertyRefElement(XmlReader reader) { PropertyRefElement property = new PropertyRefElement(ParentElement); property.Parse(reader); this.RoleProperties.Add(property); } private void HandleRoleAttribute(XmlReader reader) { string roleName; Utils.GetString(Schema, reader, out roleName); this.Name = roleName; } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { Debug.Assert(!String.IsNullOrEmpty(this.Name), "RoleName should never be empty"); IRelationship relationship = (IRelationship)this.ParentElement.ParentElement; if (!relationship.TryGetEnd(this.Name, out _end)) { AddError(ErrorCode.InvalidRoleInRelationshipConstraint, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEndRoleInRelationshipConstraint(this.Name, relationship.Name)); return; } // we are gauranteed that the _end has gone through ResolveNames, but // we are not gauranteed that it was successful if (_end.Type == null) { // an error has already been added for this return; } } internal override void Validate() { base.Validate(); // we can't resolve these names until validate because they will reference properties and types // that may not be resolved when this objects ResolveNames gets called Debug.Assert(_roleProperties != null, "xsd should have verified that there should be atleast one property ref element in referential role element"); foreach (PropertyRefElement property in _roleProperties) { if (!property.ResolveNames((SchemaEntityType)_end.Type)) { AddError(ErrorCode.InvalidPropertyInRelationshipConstraint, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidPropertyInRelationshipConstraint( property.Name, this.Name)); } } } } } // 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
- StateInitialization.cs
- AddInPipelineAttributes.cs
- HTMLTextWriter.cs
- Native.cs
- StackSpiller.Temps.cs
- XmlNodeChangedEventManager.cs
- KoreanCalendar.cs
- AssemblyNameProxy.cs
- Ref.cs
- MessageBox.cs
- WsdlExporter.cs
- ArgumentFixer.cs
- HtmlInputText.cs
- ConditionBrowserDialog.cs
- StringResourceManager.cs
- RotateTransform.cs
- PowerModeChangedEventArgs.cs
- TransportBindingElement.cs
- BmpBitmapEncoder.cs
- Int64AnimationBase.cs
- TTSEvent.cs
- ToolStripSystemRenderer.cs
- DispatcherObject.cs
- PointAnimationBase.cs
- WorkflowItemPresenter.cs
- AuthenticationConfig.cs
- StoreItemCollection.cs
- ModulesEntry.cs
- assertwrapper.cs
- NotifyIcon.cs
- Visual3D.cs
- uribuilder.cs
- Sentence.cs
- ConfigurationSectionGroupCollection.cs
- MergeLocalizationDirectives.cs
- Number.cs
- AuthenticationException.cs
- SafeReadContext.cs
- Brush.cs
- SqlClientWrapperSmiStream.cs
- Converter.cs
- ProxyWebPart.cs
- OpCodes.cs
- BaseValidator.cs
- ScalarType.cs
- PLINQETWProvider.cs
- SignatureHelper.cs
- LinkLabelLinkClickedEvent.cs
- OptimizedTemplateContent.cs
- ApplicationFileCodeDomTreeGenerator.cs
- TrackingParameters.cs
- RemotingServices.cs
- MsmqTransportSecurityElement.cs
- PrintPreviewDialog.cs
- Screen.cs
- Expander.cs
- DynamicPropertyReader.cs
- DiscoveryClientBindingElement.cs
- ZipIOCentralDirectoryFileHeader.cs
- OleDbConnectionFactory.cs
- Header.cs
- RuntimeHelpers.cs
- TraversalRequest.cs
- X509Extension.cs
- XsdBuildProvider.cs
- StatusStrip.cs
- X509UI.cs
- CanonicalFormWriter.cs
- Dispatcher.cs
- DesignerLoader.cs
- AssemblyAttributesGoHere.cs
- PointAnimationClockResource.cs
- AlternateView.cs
- DbProviderManifest.cs
- CreateInstanceBinder.cs
- AsyncDataRequest.cs
- FixedSOMTableRow.cs
- __Error.cs
- StrokeCollectionConverter.cs
- SQLDecimalStorage.cs
- ColumnHeaderConverter.cs
- EdmItemCollection.cs
- ScriptingProfileServiceSection.cs
- GroupedContextMenuStrip.cs
- SafeSystemMetrics.cs
- PropertyPathWorker.cs
- ObjectHelper.cs
- TCPClient.cs
- CodeIdentifiers.cs
- CodeExporter.cs
- SerialErrors.cs
- WriteFileContext.cs
- EdmSchemaError.cs
- DataRowComparer.cs
- MemberInfoSerializationHolder.cs
- DomNameTable.cs
- RtfControls.cs
- RTLAwareMessageBox.cs
- UsernameTokenFactoryCredential.cs
- KeyTime.cs