Decode
{
get
{
return _decode;
}
set
{
_decode = value;
}
}
private AVRPCSerialize _encode;
public AVRPCSerialize
Encode
{
get
{
if (_encode == null)
{
_encode = n =>
{
if (n != null)
return Json.Parse(n.ToString()) as IDictionary;
return null;
};
}
return _encode;
}
set
{
_encode = value;
}
}
public string FunctionName { get; set; }
public Task ExecuteAsync(P parameters)
{
return AVUser.GetCurrentAsync().OnSuccess(t =>
{
var user = t.Result;
var encodedParameters = Encode(parameters);
var command = new AVCommand(
string.Format("call/{0}", Uri.EscapeUriString(this.FunctionName)),
method: "POST",
sessionToken: user != null ? user.SessionToken : null,
data: encodedParameters);
return AVClient.RunCommandAsync(command);
}).Unwrap().OnSuccess(s =>
{
var responseBody = s.Result.Item2;
if (!responseBody.ContainsKey("result"))
{
return default(R);
}
return Decode(responseBody);
});
}
}
public class AVObjectRPCCloudFunction : AVObjectRPCCloudFunction
{
}
public class AVObjectListRPCCloudFunction : AVObjectListRPCCloudFunction
{
}
public class AVObjectListRPCCloudFunction : AVRPCCloudFunctionBase