1

我无法从 C# 使用 AsanaNet。实例化一个新的 Asana 实例时,我无法传递 errorCallback。我得到的错误是“当前上下文中不存在errorCallback”。下面是我的代码。

class Program
{
    private const string _apiKey = "API";
    private static Asana _asana;

    static void Main(string[] args)
    {
        Console.WriteLine("Step 1");
        _asana = new Asana(_apiKey, AuthenticationType.Basic, errorCallback);
        var user = new AsanaUser();
        _asana.GetMe(o =>
        {
            user = o as AsanaUser;
        });
        Console.WriteLine("Step 2");
        _asana.GetWorkspaces(o =>
        {
            foreach (AsanaWorkspace workspace in o)
            {
                Console.WriteLine("Workspace Name={0}", workspace.Name);
            }
        });
        Console.WriteLine("Step 3");
        _asana.GetWorkspaces(o =>
        {
            foreach (AsanaWorkspace workspace in o)
            {
                _asana.GetProjectsInWorkspace(workspace, projects =>
                {
                    foreach (AsanaProject project in projects)
                    {
                        Console.WriteLine("Project Name=" + project.Name);
                    }
                }
                );
            }
        });
    }
 }
4

1 回答 1

2

根据https://github.com/acron0/AsanaNet/blob/master/AsanaNet/Asana.cs,构造函数具有以下签名:

public Asana(string apiKeyOrBearerToken, AuthenticationType authType, Action<string, string, string> errorCallback)

所以你可以像这样声明你的错误回调方法:

static void errorCallback(string s1, string s2, string s3)
{

}

此外,如果您不想处理任何事情,您可以将一个空的 lambda 传递给构造函数:

_asana = new Asana(_apiKey, AuthenticationType.Basic, (s1, s2, s3) => {});
于 2013-09-26T16:36:38.843 回答