Yes, I was trying to make it general so that it would be useful for someone else working on something different in the future... here's a concrete example:
There's a method called Distance, as you mentioned, which is:
public static double Distance(IGeometry that) { ... }
It isn't an extension method but rather is an implementation method.
So I go and make a class SpatialGenerator which implements IHqlGeneratorForMethod and whose SupportedMethods property returns a list containing that Distance method, gotten by
ReflectionHelper.GetMethodDefinition<IGeometry>(x => x.Distance(null))
Then BuildHql returns using the MethodCall as you mentioned earlier...
return treeBuilder.MethodCall("NHSP.Distance", visitor.Visit(targetObject).AsExpression(), visitor.Visit(arguments[0]).AsExpression());
The generator is hooked in by a child of DefaultLinqToHqlGeneratorsRegistry that calls RegisterGenerator, and in my test's config I do
myconfig.SetProperty(Environment.LinqToHqlGeneratorsRegistry,
typeof (Extensions.SpatialGeneratorsRegistry).
AssemblyQualifiedName)
I attempt to run a query next...
var test = s.Query<TestModel.PositionRecord>().Where(x => x.Position.Distance(mylocation) <= 500).ToList();
If this were to work properly, I should receive back all PositionRecord entities where the distance from that entity to mylocation is within 500 meters. But of course I get the "No persister for: GeoAPI.Geometries.IGeometry" exception because there's no way for it to know to use the IUserType I have for IGeometry. I haven't seen any place to plug this in as of yet.