Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / ConstraintEnumerator.cs / 1305376 / ConstraintEnumerator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data { using System; using System.Diagnostics; using System.Collections; using System.ComponentModel; ////// ConstraintEnumerator is an object for enumerating all constraints in a DataSet /// internal class ConstraintEnumerator { System.Collections.IEnumerator tables; System.Collections.IEnumerator constraints; Constraint currentObject; public ConstraintEnumerator(DataSet dataSet) { tables = (dataSet != null) ? dataSet.Tables.GetEnumerator() : null; currentObject = null; } public bool GetNext() { Constraint candidate; currentObject = null; while (tables != null) { if (constraints == null) { if (!tables.MoveNext()) { tables = null; return false; } constraints = ((DataTable)tables.Current).Constraints.GetEnumerator(); } if (!constraints.MoveNext()) { constraints = null; continue; } Debug.Assert(constraints.Current is Constraint, "ConstraintEnumerator, contains object which is not constraint"); candidate = (Constraint)constraints.Current; if (IsValidCandidate(candidate)) { currentObject = candidate; return true; } } return false; } public Constraint GetConstraint() { // If currentObject is null we are before first GetNext or after last GetNext--consumer is bad Debug.Assert (currentObject != null, "GetObject should never be called w/ null currentObject."); return currentObject; } protected virtual bool IsValidCandidate(Constraint constraint) { return true; } protected Constraint CurrentObject { get { return currentObject; } } } internal class ForeignKeyConstraintEnumerator : ConstraintEnumerator { public ForeignKeyConstraintEnumerator(DataSet dataSet) : base(dataSet) { } protected override bool IsValidCandidate(Constraint constraint) { return(constraint is ForeignKeyConstraint); } public ForeignKeyConstraint GetForeignKeyConstraint() { // If CurrentObject is null we are before first GetNext or after last GetNext--consumer is bad Debug.Assert (CurrentObject != null, "GetObject should never be called w/ null currentObject."); return(ForeignKeyConstraint)CurrentObject; } } internal sealed class ChildForeignKeyConstraintEnumerator : ForeignKeyConstraintEnumerator { // this is the table to do comparisons against DataTable table; public ChildForeignKeyConstraintEnumerator(DataSet dataSet, DataTable inTable) : base(dataSet) { this.table = inTable; } protected override bool IsValidCandidate(Constraint constraint) { return((constraint is ForeignKeyConstraint) && (((ForeignKeyConstraint)constraint).Table == table)); } } internal sealed class ParentForeignKeyConstraintEnumerator : ForeignKeyConstraintEnumerator { // this is the table to do comparisons against DataTable table; public ParentForeignKeyConstraintEnumerator(DataSet dataSet, DataTable inTable) : base(dataSet) { this.table = inTable; } protected override bool IsValidCandidate(Constraint constraint) { return((constraint is ForeignKeyConstraint) && (((ForeignKeyConstraint)constraint).RelatedTable == table)); } } } // 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
- ICollection.cs
- WindowPatternIdentifiers.cs
- EntityCollectionChangedParams.cs
- DbRetry.cs
- DbConnectionPoolCounters.cs
- Latin1Encoding.cs
- handlecollector.cs
- CompoundFileDeflateTransform.cs
- ScriptControl.cs
- UnmanagedMemoryStream.cs
- QueuePropertyVariants.cs
- CodeMethodInvokeExpression.cs
- SelectionRange.cs
- SmiSettersStream.cs
- TextMetrics.cs
- Polyline.cs
- CommandBinding.cs
- ToggleProviderWrapper.cs
- TargetControlTypeAttribute.cs
- CategoryAttribute.cs
- arclist.cs
- Point4D.cs
- PrefixQName.cs
- ClientSideProviderDescription.cs
- LayoutEvent.cs
- ScrollEventArgs.cs
- URL.cs
- PropertyEntry.cs
- UnknownBitmapDecoder.cs
- KnownIds.cs
- PerspectiveCamera.cs
- DesignerActionService.cs
- ElementAction.cs
- ListViewContainer.cs
- FreeIndexList.cs
- ListControlConvertEventArgs.cs
- HwndHost.cs
- Trace.cs
- ColorAnimationUsingKeyFrames.cs
- MD5CryptoServiceProvider.cs
- PenLineCapValidation.cs
- XmlILOptimizerVisitor.cs
- DataSpaceManager.cs
- DisplayMemberTemplateSelector.cs
- GAC.cs
- HttpConfigurationSystem.cs
- HostingPreferredMapPath.cs
- DesignerAttribute.cs
- SQLCharsStorage.cs
- SerializableAttribute.cs
- BitmapMetadataEnumerator.cs
- SpellCheck.cs
- FormsAuthenticationEventArgs.cs
- Parsers.cs
- FormViewInsertedEventArgs.cs
- Int64.cs
- _FixedSizeReader.cs
- StylusDownEventArgs.cs
- entityreference_tresulttype.cs
- Region.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- TimeoutValidationAttribute.cs
- Input.cs
- AnnouncementEndpointElement.cs
- BaseUriHelper.cs
- ErrorStyle.cs
- WebExceptionStatus.cs
- SqlXmlStorage.cs
- ToolboxBitmapAttribute.cs
- InstanceHandleReference.cs
- AsymmetricAlgorithm.cs
- ListViewItemSelectionChangedEvent.cs
- Int32KeyFrameCollection.cs
- SwitchAttribute.cs
- ObfuscationAttribute.cs
- ToolStripPanelRenderEventArgs.cs
- ApplicationServicesHostFactory.cs
- IgnoreDataMemberAttribute.cs
- ApplicationId.cs
- ConnectionStringsExpressionBuilder.cs
- XmlObjectSerializerWriteContextComplex.cs
- PKCS1MaskGenerationMethod.cs
- Exception.cs
- PartitionedStream.cs
- HGlobalSafeHandle.cs
- QueryRewriter.cs
- ComponentDispatcher.cs
- MultipartContentParser.cs
- XsltOutput.cs
- StringResourceManager.cs
- OrderByBuilder.cs
- RegisteredHiddenField.cs
- SocketAddress.cs
- SqlUserDefinedTypeAttribute.cs
- AssertFilter.cs
- __ComObject.cs
- StorageFunctionMapping.cs
- XsdValidatingReader.cs
- AddInToken.cs
- FormatConvertedBitmap.cs