public async Task <D[]> GetArrayAsync <D>(ActionContext ac, string uri, int proj = 0x00ff) where D : IData, new() { try { HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, uri); if (peerid != null && ac != null) { if (ac.Token != null) { req.Headers.Add("Authorization", "Token " + ac.Token); } } HttpResponseMessage rsp = await SendAsync(req, HttpCompletionOption.ResponseContentRead); if (rsp.StatusCode != HttpStatusCode.OK) { return(null); } byte[] bytea = await rsp.Content.ReadAsByteArrayAsync(); string ctyp = rsp.Content.Headers.GetValue("Content-Type"); IDataInput inp = ParseContent(ctyp, bytea, bytea.Length); return(inp.ToArray <D>(proj)); } catch { retryat = Environment.TickCount + AHEAD; } return(null); }
public D[] ToArray <D>(int proj = 0x00ff) where D : IData, new() { IDataInput inp = entity as IDataInput; return(inp?.ToArray <D>(proj)); }