我有以下方法,它是 Google.Apis IDatastore 的实现
https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web_applications :
public Task<T> GetAsync<T>(string key)
{
var account = GetAccountById(key);
return account;
}
以上是行不通的。我得到:
Cannot implicitly convert type 'Model.Account' to 'System.Threading.Tasks.Task'
所以我不确定如何返回我的帐户。我认为这很简单,但我没有做到。
请您参考如下方法:
我认为 Task<T> 的正确实现会是这样的
public Task<T> GetAsync<T>(string key)
{
// Replace with actual logic
return Task.Factory.StartNew(() => default(T));
}
对于 Account
public Task<Account> GetAsync(string key)
{
return Task.Factory.StartNew(() => GetAccountById(key));
}
