Clone() abstract private method

abstract private Clone ( DataSet destination ) : Constraint
destination DataSet
return Constraint
Beispiel #1
0
        private void MergeConstraints(DataTable table)
        {
            Debug.Assert(_dataSet != null);

            // Merge constraints
            for (int i = 0; i < table.Constraints.Count; i++)
            {
                Constraint src  = table.Constraints[i];
                Constraint?dest = src.Clone(_dataSet, _IgnoreNSforTableLookup);

                if (dest == null)
                {
                    _dataSet.RaiseMergeFailed(table,
                                              SR.Format(SR.DataMerge_MissingConstraint, src.GetType().FullName, src.ConstraintName),
                                              _missingSchemaAction
                                              );
                }
                else
                {
                    Constraint?cons = dest.Table !.Constraints.FindConstraint(dest);
                    if (cons == null)
                    {
                        if (MissingSchemaAction.Add == _missingSchemaAction)
                        {
                            try
                            {
                                // try to keep the original name
                                dest.Table.Constraints.Add(dest);
                            }
                            catch (DuplicateNameException)
                            {
                                // if fail, assume default name
                                dest.ConstraintName = string.Empty;
                                dest.Table.Constraints.Add(dest);
                            }
                        }
                        else if (MissingSchemaAction.Error == _missingSchemaAction)
                        {
                            _dataSet.RaiseMergeFailed(table,
                                                      SR.Format(SR.DataMerge_MissingConstraint, src.GetType().FullName, src.ConstraintName),
                                                      _missingSchemaAction
                                                      );
                        }
                    }
                    else
                    {
                        MergeExtendedProperties(src.ExtendedProperties, cons.ExtendedProperties);
                    }
                }
            }
        }
Beispiel #2
0
        private void MergeConstraints(DataTable table)
        {
            // Merge constraints
            for (int i = 0; i < table.Constraints.Count; i++)
            {
                Constraint src  = table.Constraints[i];
                Constraint dest = src.Clone(dataSet);

                if (dest == null)
                {
                    dataSet.RaiseMergeFailed(table,
                                             Res.GetString(Res.DataMerge_MissingConstraint, src.GetType().FullName, src.ConstraintName),
                                             missingSchemaAction
                                             );
                }
                else
                {
                    Constraint cons = dest.Table.Constraints.FindConstraint(dest);
                    if (cons == null)
                    {
                        if (MissingSchemaAction.Add == missingSchemaAction)
                        {
                            try {
                                // try to keep the original name
                                dest.Table.Constraints.Add(dest);
                            }
                            catch (DuplicateNameException) {
                                // if fail, assume default name
                                dest.ConstraintName = "";
                                dest.Table.Constraints.Add(dest);
                            }
                        }
                        else if (MissingSchemaAction.Error == missingSchemaAction)
                        {
                            dataSet.RaiseMergeFailed(table,
                                                     Res.GetString(Res.DataMerge_MissingConstraint, src.GetType().FullName, src.ConstraintName),
                                                     missingSchemaAction
                                                     );
                        }
                    }
                    else
                    {
                        MergeExtendedProperties(src.ExtendedProperties, cons.ExtendedProperties);
                    }
                }
            }
        }
 private void MergeConstraints(DataTable table)
 {
     for (int i = 0; i < table.Constraints.Count; i++)
     {
         Constraint constraint2 = table.Constraints[i];
         Constraint constraint  = constraint2.Clone(this.dataSet, this._IgnoreNSforTableLookup);
         if (constraint == null)
         {
             this.dataSet.RaiseMergeFailed(table, Res.GetString("DataMerge_MissingConstraint", new object[] { constraint2.GetType().FullName, constraint2.ConstraintName }), this.missingSchemaAction);
         }
         else
         {
             Constraint constraint3 = constraint.Table.Constraints.FindConstraint(constraint);
             if (constraint3 == null)
             {
                 if (MissingSchemaAction.Add == this.missingSchemaAction)
                 {
                     try
                     {
                         constraint.Table.Constraints.Add(constraint);
                     }
                     catch (DuplicateNameException)
                     {
                         constraint.ConstraintName = "";
                         constraint.Table.Constraints.Add(constraint);
                     }
                 }
                 else if (MissingSchemaAction.Error == this.missingSchemaAction)
                 {
                     this.dataSet.RaiseMergeFailed(table, Res.GetString("DataMerge_MissingConstraint", new object[] { constraint2.GetType().FullName, constraint2.ConstraintName }), this.missingSchemaAction);
                 }
             }
             else
             {
                 this.MergeExtendedProperties(constraint2.ExtendedProperties, constraint3.ExtendedProperties);
             }
         }
     }
 }