简体   繁体   English

此Canon SDK C ++代码段的等效C#代码是什么?

[英]What is the equivalent C# code for this Canon SDK C++ code snippet?

What is the C# equivalent of this C++ code? 此C ++代码的C#等效项是什么?

private:
    static EdsError EDSCALLBACK ProgressFunc (
                        EdsUInt32   inPercent,
                        EdsVoid *   inContext,
                        EdsBool *   outCancel
                        )
    {
        Command *command = (Command *)inContext;
        CameraEvent e("ProgressReport", &inPercent);
        command->getCameraModel()->notifyObservers(&e);
        return EDS_ERR_OK;
    }

字里行间-有a.Net 2.0包装(包括源代码)为佳能SDK 这里和另一这里

This is a rough translation for illustration purposes: 这是出于说明目的的粗略翻译:

private static void ProgressFunc(uint percent, object context, out bool cancel)
{
    Command command = (Command)context;
    CameraEvent e = new CameraEvent("ProgressReport", percent);
    command.GetCameraModel().NotifyObservers(e);
    cancel = false;
}

( EdsError has been changed to void , because we use exceptions in C# instead of error codes; EDSCALLBACK is defined as __stdcall which is irrelevant here; the code only works if all implied classes and methods exist; idiomatic C# would be the use of event /EventHandler<T>/EventArgs instead of a "NotifyObservers" method; I assume you don't want to do any interop with C++). EdsError已更改为void ,因为我们在C#中使用异常而不是错误代码; EDSCALLBACK被定义为__stdcall ,在这里与此无关;该代码仅在所有隐含类和方法都存在的情况下才起作用;惯用的C#将使用event / EventHandler <T> / EventArgs而不是“ NotifyObservers”方法;我假设您不想与C ++进行任何互操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM