【发布时间】:2015-04-24 21:10:30
【问题描述】:
我正在尝试编写一个 C# 程序。该功能已经实现(但在 Java 中)。
有什么方法可以像在 Java 中那样在方法中实现“DeviceController.OnDeviceControllerListener”-Interface 吗? 我需要像 Java 代码示例中那样实现和自定义覆盖方法(onError、onRead 和 onInsert):
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) {
}
});
我希望你能理解我的问题。这对我来说很难解释。
【问题讨论】:
-
你可以将java代码的功能重写为C#?
-
我已经编写了所有其他功能。我的程序中有一些异步方法,最后我想返回这个方法(onError,...)
-
使用锐化等工具可以节省大量时间。
-
在我的情况下,锐化并没有真正做太多,因为我正在将应用程序从 Android 移植到 WindowsPhone
标签: java c# interface listener