private static void CollectCallArgs(MemoryStore body, Hashtable callArgs) { foreach (Statement s in new MemoryStore(body)) { // make a copy since we remove statements from b within if (FindUserPredicate(s.Predicate) == null) continue; Entity subj = s.Subject; if (!(subj is BNode)) continue; // it would be nice to exclude variables, but we've already converted bnodes to variables BNode head = (BNode)subj; ArrayList argList = new ArrayList(); while (true) { Resource[] objs = body.SelectObjects(subj, entRDFFIRST); if (objs.Length == 0) break; // if this is the first iteration, then we're just not looking at a list // on later iterations, the list must not be well-formed, so we'll just // stop reading it here argList.Add(objs[0]); // assume a properly formed list body.Remove(new Statement(subj, entRDFFIRST, null)); Resource[] rests = body.SelectObjects(subj, entRDFREST); if (rests.Length == 0) break; // not well formed body.Remove(new Statement(subj, entRDFREST, null)); if (rests[0] == entRDFNIL) break; // that's the end of the list if (!(rests[0] is Entity)) break; // also not well formed subj = (Entity)rests[0]; } if (argList.Count > 0) callArgs[head] = argList.ToArray(typeof(Resource)); } }