小编zam*_*tul的帖子

“ [DllImport(” __ Internal“)]”“-” __Internal“是什么意思?

我正在为iOS游戏而团结。要解锁成就,我需要从我的C#代码中访问“ Achievement.mm”文件:

    [DllImport("__Internal")]
    private static extern void
       GKAchievement(string achievementID, float progress, bool value);
Run Code Online (Sandbox Code Playgroud)

我从一个论坛获得了这段代码。但是,“ __ Internal”是什么意思?

c# dllimport unity-game-engine

6
推荐指数
2
解决办法
4873
查看次数

如何从作为 lambda 传递的函数接口对象实例获取参数?

@FunctionalInterface
public interface ServiceCaller {
    void callService();
}

//common method to execute any service call
public void executeService(ServiceCaller serviceCaller) {
    //do common things
    //i want to access dbValidationRequest/apiValidationRequest here for logging purpose
    try {
        serviceCaller.callService();
    } catch (Exception ex) {
        //do common things
        LogUtils.log(logger, ex);
    }
    //do common things
}

//my clients call this
public void validateFromDb(DbValidationRequest dbValidationRequest){
    commonUtils.executeService(()-> dbValidationService.validate(dbValidationRequest));
}

//my clients call this
public void validateFromApi(ApiValidationRequest apiValidationRequest){
    commonUtils.executeService(()-> apiValidationService.validate(apiValidationRequest));
}


Run Code Online (Sandbox Code Playgroud)

这是Java Spring应用程序的控制器。在executeService方法中,我传递了ServiceCaller接口的一个实例。我使用此方法从控制器调用所有服务。如果我使用 intelliJ IDEA …

java lambda functional-interface

3
推荐指数
1
解决办法
1319
查看次数