Allow resources to be matched by custom key/values

Currently the only way to lookup resources is by their name or identity attribute. It would be nice to be able to lookup on any value of the resource (such as by the 'code' attribute on a script resource).

This is a spike. I'm interested to hear feedback about this approach. If this is agreeable, I will gladly clean this up, write tests, etc.