private static XElement ExportFeatureStructure(IFsAbstractStructure absFeatStruc) { if (absFeatStruc == null) return null; switch (absFeatStruc.ClassName) { case "FsFeatStruc": var featStruc = (IFsFeatStruc)absFeatStruc; return new XElement("FsFeatStruc", new XAttribute("Id", featStruc.Hvo), CreateAttribute("Type", featStruc.TypeRA), from featureSpec in featStruc.FeatureSpecsOC select ExportFeatureSpecification(featureSpec)); default: // As of 14 November 2009, FsFeatStrucDisj is not supported. throw new ArgumentException("Unrecognized subclass."); } }
/// <summary> /// Answer true if the argument feature structure is equivalent to the recipient. /// Review JohnT: should we just call this Equals? /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsAbstractStructure other) { if (other == null) return this.IsEmpty; if (!base.IsEquivalent(other)) return false; IFsFeatStruc fs = other as IFsFeatStruc; if (fs.TypeRAHvo != this.TypeRAHvo) return false; FdoOwningCollection<IFsFeatureSpecification> otherFeatures = fs.FeatureSpecsOC; FdoOwningCollection<IFsFeatureSpecification> thisFeatures = FeatureSpecsOC; if (otherFeatures.Count != thisFeatures.Count) return false; FdoOwningCollection<IFsFeatStrucDisj> otherDisjunctions = fs.FeatureDisjunctionsOC; FdoOwningCollection<IFsFeatStrucDisj> thisDisjunctions = FeatureDisjunctionsOC; if (otherDisjunctions.Count != thisDisjunctions.Count) return false; foreach (IFsFeatureSpecification fsOther in otherFeatures) { bool fMatch = false; foreach(IFsFeatureSpecification fsThis in thisFeatures) { if (fsThis.IsEquivalent(fsOther)) { fMatch = true; break; } } if (!fMatch) return false; } foreach (IFsFeatStrucDisj fsdOther in otherDisjunctions) { bool fMatch = false; foreach(IFsFeatStrucDisj fsdThis in thisDisjunctions) { if (fsdThis.IsEquivalent(fsdOther)) { fMatch = true; break; } } if (!fMatch) return false; } return true; }
/// <summary> /// True if the two are 'equivalent'. /// </summary> /// <param name="other"></param> /// <returns></returns> public override bool IsEquivalent(IFsAbstractStructure other) { if (!base.IsEquivalent(other)) return false; FdoOwningCollection<IFsFeatStruc> otherContents = (other as IFsFeatStrucDisj).ContentsOC; FdoOwningCollection<IFsFeatStruc> thisContents = ContentsOC; if (otherContents.Count != thisContents.Count) return false; foreach (IFsFeatStruc fsOther in otherContents) { bool fMatch = false; foreach(IFsFeatStruc fsThis in thisContents) { if (fsThis.IsEquivalent(fsOther)) { fMatch = true; break; } } if (!fMatch) return false; } return true; }
/// <summary> /// True if the objects are considered equivalent. This base class has no properties so /// the objects are trivially equivalent if of the same class. /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual bool IsEquivalent(IFsAbstractStructure other) { if (other == null) return false; return other.GetType() == GetType(); }