System.Data.XmlSchemaWriter.WriteConstraints C# (CSharp) Method

WriteConstraints() private method

private WriteConstraints ( ) : void
return void
		private void WriteConstraints ()
		{
			ArrayList names = new ArrayList ();

			// add all unique constraints.
			foreach (DataTable table in tables) {
				foreach (Constraint c in table.Constraints) {
					UniqueConstraint u =
						c as UniqueConstraint;
					if (u != null) {
						AddUniqueConstraints (u, names);
						continue;
					}

					ForeignKeyConstraint fk = c as ForeignKeyConstraint;
					bool haveConstraint = false;
					if (relations != null) {
						foreach (DataRelation r in relations)
							if (r.RelationName == fk.ConstraintName)
								haveConstraint = true;
					}
					if (tables.Length > 1 && fk != null && !haveConstraint) {
						DataRelation rel = new DataRelation (fk.ConstraintName,
										fk.RelatedColumns, fk.Columns);
						AddForeignKeys (rel, names, true);
						continue;
					}
				}
			}

			// Add all foriegn key constraints.
			if (relations != null)
				foreach (DataRelation rel in relations) {
					if (rel.ParentKeyConstraint == null || rel.ChildKeyConstraint == null) {
						annotation.Add (rel);
						continue;
					}
					AddForeignKeys (rel, names,false);
				}
		}