Expose InfoProvider result via custom macro expression

Stephen Rushing asked on April 10, 2015 23:03

I have a custom macro method that is essentially doing a TreeProvider.SelectNodes() call, and I'd like to provide that through the macro method in the same way that Documents is exposed.

I'd like to be able to refine the query, i.e. {% MyMacroMethod().Columns(...).Where(...) %}, then iterate through the TreeNode results.

Right now, I just get a generic enumerable context list, with methods like All, Any, Exists, etc.

With another macro method, it took me FOREVER to figure out that I needed to wrap my Dictionary with new DictionaryContainer(dict), so maybe there's a similar wrapper for InfoProvider queries.

If not, I'm assuming I need to do some more extensive stuff through MacroFields, but I'm not finding docs on how to do that or what fields I would need to provide.

Recent Answers


Stephen Rushing answered on April 13, 2015 19:04

This turned out to be pretty simple.

In my macro method...

return new TreeNodeCollection("custom.pagetype", tree.SelectNodes().Where(...).Execute());

TreeNodeCollection is an extension of ObjectCollection, which is also extended by InfoObjectCollection, but I've not experimented with that yet.

Since the query can be modified with Columns(), Where(), etc methods after being provided through the macro, I'm curious how to avoid calling Execute(), for efficiency's sake.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.