What is the function in rhinocommon to test if point is in a curve?

I tried this one, but polyline function return always false, and only true when the point is on top of polyline point and false when inside closed polyline.
There is no way check this function for polylines?

private void RunScript(Point3d x, Polyline y, ref object A)
{
A = y.Contains(x);
B = y.ToPolylineCurve().Contains(x);
}

Is there also any function to find closest point on polyline or polyline first has to be converted to curve?

One solution I know is to make a half infinite line going from the point to test, you get the number of intersections
if uneven => inside,
if even => inside