I have a semi-general class that gets Func<>from another class to tell it how to convert data. In a somewhat truncated form, the code is as follows:
public class A
{
public B b;
public void init()
{
b = new B(ConvertRawData);
}
public double ConvertRawData(double rawData)
{
if(rawData == 1023)
RaiseMalfunctionEvent();
return rawData;
}
public void CalculateData(double rawData)
{
b.CalculateData(rawData);
}
}
public class B
{
event EventHandler Malfunction;
Func<double, double> _converter;
public B(Func<double, double> converter)
{
_converter = converter;
}
public void CalculateData(rawData)
{
var myVal = _converter(rawData);
}
}
What I want to do is the ability to raise the event in Func<>, but be able to handle this event in class B. Currently the event is really raised in class A.
So my question is, how can I make class B without publishing a public event handler in class B? Or is it possible?
Edit
, . . 1023, , , , ?