using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
namespace sharpcomparer
{
public class TableComparison : Comparison
{
public TableComparison(Table itemLeft, Table itemRight, ComparisonDifference difference) : base(itemLeft, itemRight, difference)
{
}
public string Type
{
get
{
return LeftItem != null ? LeftItem.TableType : RightItem.TableType;
}
}
public string Name
{
get
{
return LeftItem != null ? LeftItem.TableName : RightItem.TableName;
}
}
public string Owner
{
get
{
return LeftItem != null ? LeftItem.TableSchema : RightItem.TableSchema;
}
}
public List Columns
{
get
{
return LeftItem != null ? LeftItem.Columns : RightItem.Columns;
}
}
public static List Compare(List left, List right)
{
List comparison = new List();
foreach (Table table in left)
{
Table result = right.Find(
delegate(Table t)
{
return t.TableName == table.TableName;
}
);
if (result != null)
{
if (table != result)
{
comparison.Add(new TableComparison(table, result, ComparisonDifference.Different));
}
else
{
comparison.Add(new TableComparison(table, result, ComparisonDifference.None));
}
}
else
{
comparison.Add(new TableComparison(table, null, ComparisonDifference.LeftOnly));
}
}
foreach (Table table in right)
{
Table result = left.Find(
delegate(Table t)
{
return t.TableName == table.TableName;
}
);
if (result == null)
{
comparison.Add(new TableComparison(null, table, ComparisonDifference.RightOnly));
}
}
return comparison;
}
}
}