Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / Constraint.cs / 1 / Constraint.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.ComponentModel;
using System.Globalization;
///
/// Represents a constraint that can be enforced on one or
/// more objects.
///
[
DefaultProperty("ConstraintName"),
TypeConverter(typeof(ConstraintConverter))
]
#if WINFSInternalOnly
internal
#else
public
#endif
abstract class Constraint {
internal String name = "";
private String _schemaName = "";
private bool inCollection = false;
private DataSet dataSet = null;
internal PropertyCollection extendedProperties = null;
///
/// The name of this constraint within the
/// .
///
[
DefaultValue(""),
ResDescriptionAttribute(Res.ConstraintNameDescr),
ResCategoryAttribute(Res.DataCategory_Data)
]
public virtual string ConstraintName {
get {
return name;
}
set {
if (value == null)
value = "";
if (Common.ADP.IsEmpty(value) && (Table != null) && InCollection)
throw ExceptionBuilder.NoConstraintName();
CultureInfo locale = (Table != null ? Table.Locale : CultureInfo.CurrentCulture);
if (String.Compare(name, value, true, locale) != 0) {
if ((Table != null) && InCollection) {
Table.Constraints.RegisterName(value);
if (name.Length != 0)
Table.Constraints.UnregisterName(name);
}
name = value;
}
else if (String.Compare(name, value, false, locale) != 0) {
name = value;
}
}
}
internal String SchemaName {
get {
if (Common.ADP.IsEmpty(_schemaName))
return ConstraintName;
else
return _schemaName;
}
set {
if (!Common.ADP.IsEmpty(value))
_schemaName = value;
}
}
internal virtual bool InCollection {
get { // ACCESSOR: virtual was missing from this get
return inCollection;
}
set {
inCollection = value;
if (value)
dataSet = Table.DataSet;
else
dataSet = null;
}
}
///
/// Gets the to which the constraint applies.
///
[ResDescriptionAttribute(Res.ConstraintTableDescr)]
public abstract DataTable Table {
get;
}
///
/// Gets the collection of customized user information.
///
[
ResCategoryAttribute(Res.DataCategory_Data),
Browsable(false),
ResDescriptionAttribute(Res.ExtendedPropertiesDescr)
]
public PropertyCollection ExtendedProperties {
get {
if (extendedProperties == null) {
extendedProperties = new PropertyCollection();
}
return extendedProperties;
}
}
internal abstract bool ContainsColumn(DataColumn column);
internal abstract bool CanEnableConstraint();
internal abstract Constraint Clone(DataSet destination);
internal abstract Constraint Clone(DataSet destination, bool ignoreNSforTableLookup);
internal void CheckConstraint() {
if (!CanEnableConstraint()) {
throw ExceptionBuilder.ConstraintViolation(ConstraintName);
}
}
internal abstract void CheckCanAddToCollection(ConstraintCollection constraint);
internal abstract bool CanBeRemovedFromCollection(ConstraintCollection constraint, bool fThrowException);
internal abstract void CheckConstraint(DataRow row, DataRowAction action);
internal abstract void CheckState();
protected void CheckStateForProperty() {
try {
CheckState();
}
catch (Exception e) {
//
if (!Common.ADP.IsCatchableExceptionType (e)) {
throw;
}
throw ExceptionBuilder.BadObjectPropertyAccess(e.Message);
}
}
///
/// Gets the to which this constraint belongs.
///
#if WINFSInternalOnly
#else
[CLSCompliant(false)]
#endif
protected virtual DataSet _DataSet {
get {
return dataSet;
}
}
///
/// Sets the constraint's .
///
protected internal void SetDataSet(DataSet dataSet) {
this.dataSet = dataSet;
}
internal abstract bool IsConstraintViolated();
public override string ToString() {
return ConstraintName;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LowerCaseStringConverter.cs
- AstTree.cs
- BaseWebProxyFinder.cs
- DocumentXmlWriter.cs
- XmlSchemaSimpleTypeList.cs
- Tracking.cs
- PeerCollaboration.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- OleDbParameter.cs
- ZoneButton.cs
- CompilerTypeWithParams.cs
- ProgressiveCrcCalculatingStream.cs
- SpoolingTask.cs
- ServicePointManagerElement.cs
- RepeaterItemEventArgs.cs
- PrintDialog.cs
- MetadataWorkspace.cs
- InputProviderSite.cs
- DetailsView.cs
- RenderDataDrawingContext.cs
- GlyphRunDrawing.cs
- OleDbWrapper.cs
- SqlUserDefinedTypeAttribute.cs
- path.cs
- DataGridPagerStyle.cs
- Italic.cs
- HtmlTableRowCollection.cs
- GlyphRunDrawing.cs
- UnionCodeGroup.cs
- MailMessage.cs
- XPathNavigatorReader.cs
- ElementMarkupObject.cs
- ConfigurationValues.cs
- LayoutTableCell.cs
- WebPartRestoreVerb.cs
- HasCopySemanticsAttribute.cs
- PropertyGroupDescription.cs
- HttpResponse.cs
- XamlWriterExtensions.cs
- StyleXamlTreeBuilder.cs
- WebConfigurationHostFileChange.cs
- SmiContextFactory.cs
- IndexedWhereQueryOperator.cs
- XsltException.cs
- MaterialGroup.cs
- PathGeometry.cs
- XmlQueryType.cs
- HtmlTableRow.cs
- SimpleBitVector32.cs
- MimeTypePropertyAttribute.cs
- OdbcParameter.cs
- XmlSchemaSet.cs
- TreePrinter.cs
- ZipIOExtraFieldPaddingElement.cs
- PenLineJoinValidation.cs
- ObjectItemAssemblyLoader.cs
- ColorConvertedBitmap.cs
- BaseUriHelper.cs
- XmlDocument.cs
- Geometry3D.cs
- BadImageFormatException.cs
- XmlSchemaException.cs
- WebSysDisplayNameAttribute.cs
- MenuItemCollection.cs
- AttributeCollection.cs
- MimeXmlImporter.cs
- OdbcRowUpdatingEvent.cs
- StateManagedCollection.cs
- WebControlAdapter.cs
- WebConfigurationHost.cs
- SubMenuStyleCollection.cs
- EventWaitHandle.cs
- XPathCompileException.cs
- TextMetrics.cs
- DataTemplate.cs
- Decoder.cs
- SigningProgress.cs
- XmlWriterDelegator.cs
- ClientUtils.cs
- SimpleBitVector32.cs
- Transform.cs
- InvokeHandlers.cs
- JavascriptCallbackBehaviorAttribute.cs
- OperatingSystem.cs
- CodePageEncoding.cs
- DoubleCollectionValueSerializer.cs
- GenericXmlSecurityToken.cs
- DefaultHttpHandler.cs
- BoundField.cs
- PropertyToken.cs
- EnumMemberAttribute.cs
- NestPullup.cs
- MatrixAnimationUsingKeyFrames.cs
- WsatTransactionHeader.cs
- WhitespaceRuleReader.cs
- SchemaNotation.cs
- QueryAsyncResult.cs
- WindowsListViewScroll.cs
- ServicePointManager.cs
- _PooledStream.cs