Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / ReferentialConstraintRoleElement.cs / 2 / 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
- TrackingCondition.cs
- TcpConnectionPool.cs
- EditingCoordinator.cs
- LoginCancelEventArgs.cs
- StrokeNodeEnumerator.cs
- DateTimeFormatInfoScanner.cs
- ScriptControlDescriptor.cs
- ObfuscateAssemblyAttribute.cs
- BooleanSwitch.cs
- Evidence.cs
- NavigationHelper.cs
- Listbox.cs
- CommonObjectSecurity.cs
- Transform3DGroup.cs
- ToolStripContentPanelRenderEventArgs.cs
- AuthenticatedStream.cs
- WebPartConnectionsCancelVerb.cs
- IntPtr.cs
- DriveInfo.cs
- XmlIlVisitor.cs
- MenuItemStyle.cs
- DBSchemaTable.cs
- propertyentry.cs
- Double.cs
- DefaultValueAttribute.cs
- FrameAutomationPeer.cs
- EventLogSession.cs
- XmlDataSourceNodeDescriptor.cs
- FontWeight.cs
- XPathMultyIterator.cs
- ReadOnlyCollectionBuilder.cs
- SerializationAttributes.cs
- XXXOnTypeBuilderInstantiation.cs
- VoiceSynthesis.cs
- SimpleHandlerFactory.cs
- DictionaryGlobals.cs
- SiteMapDataSource.cs
- ToolStripDropDown.cs
- XpsInterleavingPolicy.cs
- XmlValidatingReader.cs
- LinqDataView.cs
- DocumentScope.cs
- ReadOnlyMetadataCollection.cs
- ListViewItem.cs
- MailMessage.cs
- CorruptingExceptionCommon.cs
- DocumentSequenceHighlightLayer.cs
- PlanCompiler.cs
- Renderer.cs
- InheritedPropertyChangedEventArgs.cs
- HttpModulesSection.cs
- XmlILConstructAnalyzer.cs
- XamlStyleSerializer.cs
- ToolStripGrip.cs
- ViewBox.cs
- AuthStoreRoleProvider.cs
- SortQuery.cs
- WeakEventTable.cs
- Assert.cs
- SharedDp.cs
- SettingsAttributeDictionary.cs
- BindingSource.cs
- CompilerTypeWithParams.cs
- ConfigXmlComment.cs
- ProcessModelInfo.cs
- TransactionInterop.cs
- PrinterResolution.cs
- SerializationAttributes.cs
- SynchronizedInputAdaptor.cs
- RegexParser.cs
- PersonalizationProviderHelper.cs
- MemoryPressure.cs
- SafeRegistryHandle.cs
- OdbcEnvironmentHandle.cs
- HandleValueEditor.cs
- PreparingEnlistment.cs
- ImageResources.Designer.cs
- ListViewEditEventArgs.cs
- EdmEntityTypeAttribute.cs
- ScriptIgnoreAttribute.cs
- ManifestResourceInfo.cs
- PersonalizationStateInfoCollection.cs
- ClientEventManager.cs
- SocketAddress.cs
- SurrogateEncoder.cs
- Int16AnimationUsingKeyFrames.cs
- MembershipUser.cs
- NullableIntMinMaxAggregationOperator.cs
- MaskedTextProvider.cs
- SafeThemeHandle.cs
- SupportingTokenSpecification.cs
- ApplicationException.cs
- AdapterUtil.cs
- RoleManagerEventArgs.cs
- Enlistment.cs
- InternalResources.cs
- WindowsScrollBarBits.cs
- InheritanceContextChangedEventManager.cs
- RefType.cs
- PathGeometry.cs