Cast Boolean error

We have our own component that returns System.Boolean but dispatch does not work with this,
Any idea how to fix it and why we have this error?

Output as string (looks like the IGHgoo casting doesn’t pick it up)

or more precisely its reading it as an object vs the values in the object (not my arena, trying to learn here myself)

thanks for help @kike, solution was to add casting

public override bool CastTo<Y>(ref Y target)
{
    if (Value == null)
        return false;

    if (Value.GetType().IsAssignableFrom(typeof(Y)))
    {
        target = (Y)Value;
        return true;
    }

    if (typeof(Y) == typeof(object))
    {
        target = (Y)Value;
        return true;
    }

    if(typeof(Y) == typeof(GH_ObjectWrapper))
    {
        target = (Y)(object)(new GH_ObjectWrapper(Value));
        return true;
    }
    if (typeof(Y) == typeof(GH_Boolean))
    {
        if(Value is bool)
        {
            target = (Y)(object)(new GH_Boolean((bool)Value));
            return true;
        }
        if(Value is int)
        {
            target = (Y)(object)(new GH_Boolean((int)Value == 1));
            return true;
        }
    }


        return base.CastTo<Y>(ref target);
}
1 Like