Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created August 19, 2011 19:36
Show Gist options
  • Select an option

  • Save jmarnold/1157781 to your computer and use it in GitHub Desktop.

Select an option

Save jmarnold/1157781 to your computer and use it in GitHub Desktop.
ModelFinder
public class ModelFinder : IModelFinder
{
private readonly BehaviorGraph _graph;
public ModelFinder(BehaviorGraph graph)
{
_graph = graph;
}
public Type FindRelatedModel(Type type)
{
var post = _graph
.BehaviorFor(type)
.FirstCall();
// The handler Type is the CreateEndpoint so grab the Get method
var getModelType = post
.HandlerType
.GetMethod("Get", BindingFlags.Public | BindingFlags.Instance)
.GetParameters()[0]
.ParameterType;
return getModelType;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment