/// <summary> Evaluates this rule against a SifDataObject and returns the text value /// of the <c><OtherId></c> element that satisfied the query. If /// the OtherIdMapping passed to the constructor included a <i>prefix</i> /// attribute, the returned value will exclude the prefix string. /// /// </summary> /// <param name="data">The SifDataObject the rule is evaluated against /// </param> /// <returns> The value of the <c><OtherId></c> element that /// satisfied the query (excluding the prefix string if applicable), or /// null if no match found /// </returns> /// <param name="version">The SIFVersion to use while evaluating the data object</param> private SifSimpleType Evaluate(SifDataObject data, SifVersion version) { if (data != null) { // // Search all of the OtherId children for one that matches the type // and optionally the prefix specified by the fMapping // ICollection otherIdList = (ICollection)data.GetChild("OtherIdList"); if (otherIdList != null) { foreach (SifElement otherId in otherIdList) { // Compare the Type attribute SimpleField typ = otherId.GetField("Type"); if (typ == null || !typ.TextValue.Equals(fMapping.Type)) { continue; } // Optionally compare the prefix and if its a match return // all text after the prefix string String prefix = fMapping.Prefix; if (prefix != null) { String val = otherId.TextValue; if (val != null && val.StartsWith(prefix)) { return(new SifString(val.Substring(prefix.Length))); } } else { return(otherId.SifValue); } } } } return(null); }