C# class member function pointer and c++ this->*func
You could create another delegate that takes ModbusData
and MBSFrame
which is not bound to a specified target and pass the current instance to it.
public delegate void ModDataFunc(MBSFrame Frame);
private delegate void StaticModDataFunc(ModbusData ths, MBSFrame Frame);
private bool ScannAll(StaticModDataFunc func, MBSFrame Frame)
{
if (Frame.MatchAddress(MyBaseAddr, MySize))
{
func(this, Frame);
RaiseValueReadEvent(Frame.DataAddress, Frame.DataCount);
return true;
}
else
{
if (NextData != null)
{
return NextData.ScannAll(func, Frame);
}
return false;
}
}
public bool ScannAll(ModDataFunc func, MBSFrame Frame)
{
return ScannAll(func.Method.CreateDelegate<StaticModDataFunc>(), Frame);
}