public bool Equals(HorseChildDetails raceToCompareTo) { if (raceToCompareTo == null) { return(false); } return(ChildName.ToLower().Equals(raceToCompareTo.ChildName.ToLower())); }
public Component Find(string RelativePath) { // ------------------------------------------------------ // Will look for a child component using the relative // path passed in. e.g. Child/SubChild // ------------------------------------------------------ string ChildName, Remainder; int PosDelimiter = RelativePath.IndexOf(Delimiter); if (PosDelimiter != -1) { ChildName = RelativePath.Substring(0, PosDelimiter); Remainder = RelativePath.Substring(PosDelimiter + 1); } else { ChildName = RelativePath; Remainder = ""; } if (ChildName == "..") { if (Remainder == "") { return(Parent); } else { return(Parent.Find(Remainder)); } } foreach (Component Child in ChildNodes) { if (Child.Name.ToLower() == ChildName.ToLower()) { if (Remainder == "") { return(Child); } else { return(Child.Find(Remainder)); } } } return(null); }
public static XmlNode Find(XmlNode Node, string NamePath) { // ---------------------------------------------------- // Find a child with the specified NamePath. NamePath // can be a single child name or a path delimited with // '/' characters e.g. ChildNode/SubChildNode or /RootNode/ChildNode // Returns null if no child found. // ---------------------------------------------------- if (Node == null) { return(null); } if (NamePath == "") { throw new Exception("Cannot call FindByName with a blank path"); } if (NamePath[0] == Delimiter) { Node = Node.OwnerDocument.DocumentElement; int Pos = NamePath.IndexOf(Delimiter, 1); string RootName; if (Pos == -1) { RootName = NamePath.Substring(1); NamePath = ""; } else { RootName = NamePath.Substring(1, Pos - 1); NamePath = NamePath.Substring(Pos + 1); } if (RootName.ToLower() != Name(Node).ToLower()) { return(null); } if (NamePath == "") { return(Node); } } string ChildName, Remainder; int PosDelimiter = NamePath.IndexOf(Delimiter); if (PosDelimiter != -1) { ChildName = NamePath.Substring(0, PosDelimiter); Remainder = NamePath.Substring(PosDelimiter + 1); } else { ChildName = NamePath; Remainder = ""; } if (ChildName == "..") { return(Find(Node.ParentNode, Remainder)); } else if (ChildName.Length > 0 && ChildName[0] == '@') { return(Node.Attributes[ChildName.Substring(1)]); } else { foreach (XmlNode Child in Node.ChildNodes) { if (Name(Child).ToLower() == ChildName.ToLower()) { if (Remainder == "") { return(Child); } else { return(Find(Child, Remainder)); } } } } return(null); }
public override int GetHashCode() { return(ChildName.ToLower().GetHashCode()); }