public bool Equals (TypedObject other) {
// ? one is list with one member, another is not list -- still might be equal
if (this.Dim != other.Dim) {
return false;
}
if (this.Type != other.Type) {
//Check if types are comparable
if (! (this.Type.IsComparable(other.Type)) ) {
return false;
}
other.SetDecimal(); // can't use cast and other.Type.IsEqual (value1, value2)
this.SetDecimal();
if (this.IsDecimal && other.IsDecimal) { //Both are decimal / derived types
return this.ListDValueEquals(other);
}
}
// not-Decimal derivation or type equal
if (this.IsList) {
if (other.IsList) { //Both are lists and values are XmlAtomicValue[] or clrvalue[]. So use Datatype_List.Compare
return this.Type.Compare(this.Value, other.Value) == 0;
}
else { //this is a list and other is a single value
Array arr1 = this.Value as System.Array;
XmlAtomicValue[] atomicValues1 = arr1 as XmlAtomicValue[];
if (atomicValues1 != null) { // this is a list of union
return atomicValues1.Length == 1 && atomicValues1.GetValue(0).Equals(other.Value);
}
else {
return arr1.Length == 1 && arr1.GetValue(0).Equals(other.Value);
}
}
}
else if (other.IsList) {
Array arr2 = other.Value as System.Array;
XmlAtomicValue[] atomicValues2 = arr2 as XmlAtomicValue[];
if (atomicValues2 != null) { // other is a list of union
return atomicValues2.Length == 1 && atomicValues2.GetValue(0).Equals(this.Value);
}
else {
return arr2.Length == 1 && arr2.GetValue(0).Equals(this.Value);
}
}
else { //Both are not lists
return this.Value.Equals(other.Value);
}
}
}