public void AlignTo(Context other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (this.Target != null)
{
throw new InvalidOperationException(
"The source context is already aligned to another context. "
+ "Make sure to clear the target of the source context before aligning it to another one.");
}
if (other.Target != null)
{
throw new InvalidOperationException(
"The target context is already aligned to another context. "
+ "Make sure to clear the target of the target context before aligning it to another one.");
}
if (this.GetType() != other.GetType())
{
throw new ArgumentException(
"The target context has a different type than the source context. "
+ "Aligned contexts have to be of the same type.",
"other");
}
this.Target = other;
other.Target = this;
}