I have a resources in my application which inherit from SomeCellBase
, which implements the IProcessDataPublisher
interface as shown below
[ResourceRegistration]
public abstract class SomeCellBase : Cell, IProcessDataPublisher
{
protected virtual void OnProcessDataOccured(Measurement measurement)
{
ProcessDataOccurred?.Invoke(this, measurement);
}
public event EventHandler<Measurement> ProcessDataOccurred;
}
I also have a reference to the Moryx.ProcessData.Adapter.ResourceManagement package in my application.
However the ProcessDataOccurred
EventHandler is always null, as if the resource would not have been registered by the adapter.
Through the facade of the ResourceManagement
you don't receive your original object, but instead a runtime generated proxy with the same public resource interfaces.
For that the ProxyGenerator
only searches for interfaces derived from IResource
to avoid accidently publishing access to IDisposable
for example. Any non resources interfaces that should also be visible, must be exported using the ResourceAvailabeAsAttribute
In your case:
[ResourceRegistration, ResourceAvailableAs(typeof(IProcessDataPublisher))]
public abstract class SomeCellBase : Cell, IProcessDataPublisher
{
protected virtual void OnProcessDataOccured(Measurement measurement)
{
ProcessDataOccurred?.Invoke(this, measurement);
}
public event EventHandler<Measurement> ProcessDataOccurred;
}