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
- ViewBox.cs
- AnnotationAdorner.cs
- SecurityDescriptor.cs
- ViewCellSlot.cs
- CommonRemoteMemoryBlock.cs
- SmiContext.cs
- DesignerLoader.cs
- Int64.cs
- ContentDefinition.cs
- DecoderNLS.cs
- BufferedWebEventProvider.cs
- SQlBooleanStorage.cs
- TextTrailingCharacterEllipsis.cs
- XmlSchemaDocumentation.cs
- CheckBoxRenderer.cs
- ClipboardData.cs
- DeviceContexts.cs
- Parser.cs
- ServiceHttpHandlerFactory.cs
- CodeGeneratorOptions.cs
- WeakRefEnumerator.cs
- HttpResponseInternalWrapper.cs
- RequestDescription.cs
- AttributeTableBuilder.cs
- AuthenticationService.cs
- CodeArgumentReferenceExpression.cs
- NumericUpDownAcceleration.cs
- ThreadStaticAttribute.cs
- ControlBuilderAttribute.cs
- Empty.cs
- PolyQuadraticBezierSegment.cs
- ScriptResourceAttribute.cs
- Lasso.cs
- NameValuePair.cs
- ScriptRef.cs
- PathSegment.cs
- LinqDataSourceHelper.cs
- MdImport.cs
- dsa.cs
- IxmlLineInfo.cs
- ReadWriteObjectLock.cs
- TimeSpanValidator.cs
- FtpCachePolicyElement.cs
- CaseStatementSlot.cs
- DataGridColumnFloatingHeader.cs
- IntegerValidator.cs
- MatrixValueSerializer.cs
- HyperLinkColumn.cs
- TextChange.cs
- DataGridBeginningEditEventArgs.cs
- WeakReferenceKey.cs
- HotSpotCollection.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- XmlBinaryReader.cs
- ipaddressinformationcollection.cs
- HtmlElementErrorEventArgs.cs
- CreateParams.cs
- DrawingContextWalker.cs
- OleDbRowUpdatingEvent.cs
- Deserializer.cs
- NotifyCollectionChangedEventArgs.cs
- LineBreak.cs
- SkewTransform.cs
- ContextProperty.cs
- MessageDispatch.cs
- XsdBuildProvider.cs
- Path.cs
- DefaultSection.cs
- VisualStateGroup.cs
- UnsafeNetInfoNativeMethods.cs
- _HTTPDateParse.cs
- HtmlInputPassword.cs
- EmissiveMaterial.cs
- ImageInfo.cs
- StringDictionary.cs
- SparseMemoryStream.cs
- BulletChrome.cs
- VisualStateChangedEventArgs.cs
- PointLightBase.cs
- ToolStripOverflowButton.cs
- NullReferenceException.cs
- DataObjectSettingDataEventArgs.cs
- Vector3DValueSerializer.cs
- NetworkInformationPermission.cs
- sapiproxy.cs
- TdsParserSafeHandles.cs
- ChildDocumentBlock.cs
- XmlDataImplementation.cs
- FlowLayout.cs
- NativeMethods.cs
- SafeBitVector32.cs
- BindingFormattingDialog.cs
- PenThread.cs
- SimpleType.cs
- WebBrowserUriTypeConverter.cs
- HtmlMeta.cs
- CreateParams.cs
- CompilerWrapper.cs
- BezierSegment.cs
- InvokePatternIdentifiers.cs