Reputation: 799
I'm trying to write a C# program. The functionality is already implemented (But in Java).
Is there any way to implement the "DeviceController.OnDeviceControllerListener"-Interface right in the method like in Java? I need to implement and customize the override-methods(onError, onRead and onInsert) like in the Java code example:
deviceController.setOnDeviceControllerListener(new DeviceController.OnDeviceControllerListener() {
@Override
public void onError(ControllerError.Error error, String message) {
}
@Override
public void onRead(MobileServiceList<Device> devices) {
if(devices == null || devices.size() == 0) {
deviceController.insert(context, device);
}
}
@Override
public void onInsert(Device device) {
}
});
I hope you understand my problem. It's hard to explain for me.
Upvotes: 3
Views: 1326
Reputation: 2970
create your own interface like
interface IOnDeviceControllerListener
{
void OnError(ControllerError.Error error, String message);
void OnRead(MobileServiceList<Device> devices);
void OnInsert(Device device);
}
next class:
DeviceControllerListener : IOnDeviceControllerListener
{
// implementation
}
In your controller define method (in your case setOnDeviceControllerListener) which parameter is IOnDeviceControllerListener, set implementation in this case DeviceControllerListener and in implementation of devicecontroller class call methods of IOnDeviceControllerListener
Upvotes: 2