Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Constraint.cs
Go to the documentation of this file.
5
6namespace System.Data;
7
8[DefaultProperty("ConstraintName")]
10public abstract class Constraint
11{
12 private string _schemaName = string.Empty;
13
14 private bool _inCollection;
15
17
18 internal string _name = string.Empty;
19
21
22 [DefaultValue("")]
23 public virtual string ConstraintName
24 {
25 get
26 {
27 return _name;
28 }
29 [param: AllowNull]
30 set
31 {
32 if (value == null)
33 {
34 value = string.Empty;
35 }
36 if (string.IsNullOrEmpty(value) && Table != null && InCollection)
37 {
39 }
41 if (string.Compare(_name, value, ignoreCase: true, culture) != 0)
42 {
43 if (Table != null && InCollection)
44 {
46 if (_name.Length != 0)
47 {
49 }
50 }
51 _name = value;
52 }
53 else if (string.Compare(_name, value, ignoreCase: false, culture) != 0)
54 {
55 _name = value;
56 }
57 }
58 }
59
60 internal string SchemaName
61 {
62 get
63 {
64 if (!string.IsNullOrEmpty(_schemaName))
65 {
66 return _schemaName;
67 }
68 return ConstraintName;
69 }
70 set
71 {
72 if (!string.IsNullOrEmpty(value))
73 {
75 }
76 }
77 }
78
79 internal virtual bool InCollection
80 {
81 get
82 {
83 return _inCollection;
84 }
85 set
86 {
88 _dataSet = (value ? Table.DataSet : null);
89 }
90 }
91
92 public abstract DataTable? Table { get; }
93
94 [Browsable(false)]
96
97 [CLSCompliant(false)]
98 protected virtual DataSet? _DataSet => _dataSet;
99
100 internal Constraint()
101 {
102 }
103
104 internal abstract bool ContainsColumn(DataColumn column);
105
106 internal abstract bool CanEnableConstraint();
107
109
110 internal abstract Constraint Clone(DataSet destination, bool ignoreNSforTableLookup);
111
112 internal void CheckConstraint()
113 {
114 if (!CanEnableConstraint())
115 {
117 }
118 }
119
120 internal abstract void CheckCanAddToCollection(ConstraintCollection constraint);
121
122 internal abstract bool CanBeRemovedFromCollection(ConstraintCollection constraint, bool fThrowException);
123
124 internal abstract void CheckConstraint(DataRow row, DataRowAction action);
125
126 internal abstract void CheckState();
127
128 protected void CheckStateForProperty()
129 {
130 try
131 {
132 CheckState();
133 }
134 catch (Exception ex) when (ADP.IsCatchableExceptionType(ex))
135 {
137 }
138 }
139
140 protected internal void SetDataSet(DataSet dataSet)
141 {
142 _dataSet = dataSet;
143 }
144
145 internal abstract bool IsConstraintViolated();
146
147 public override string ToString()
148 {
149 return ConstraintName;
150 }
151}
static bool IsCatchableExceptionType(Exception e)
Definition ADP.cs:790
virtual ? DataSet _DataSet
Definition Constraint.cs:98
PropertyCollection _extendedProperties
Definition Constraint.cs:20
PropertyCollection ExtendedProperties
Definition Constraint.cs:95
virtual bool InCollection
Definition Constraint.cs:80
void SetDataSet(DataSet dataSet)
void CheckCanAddToCollection(ConstraintCollection constraint)
bool ContainsColumn(DataColumn column)
bool CanBeRemovedFromCollection(ConstraintCollection constraint, bool fThrowException)
Constraint Clone(DataSet destination, bool ignoreNSforTableLookup)
void CheckConstraint(DataRow row, DataRowAction action)
virtual string ConstraintName
Definition Constraint.cs:24
Constraint Clone(DataSet destination)
override string ToString()
ConstraintCollection Constraints
Definition DataTable.cs:332
static Exception ConstraintViolation(string constraint)
static Exception NoConstraintName()
static Exception BadObjectPropertyAccess(string error)
virtual string Message
Definition Exception.cs:100
static CultureInfo CurrentCulture