本文整理汇总了C#中IAdapter.GetSeriesNamesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IAdapter.GetSeriesNamesAsync方法的具体用法?C# IAdapter.GetSeriesNamesAsync怎么用?C# IAdapter.GetSeriesNamesAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAdapter
的用法示例。
在下文中一共展示了IAdapter.GetSeriesNamesAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public async static Task Handle(HttpContext ctx, IAdapter adapter, JsonSerializer serializer, string predefinedPages)
{
ctx.Response.StatusCode = 200;
// Response is cached in a MemoryStream first rather than writing directly to ctx.Response.Body
// so that a 501 can be sent in the event of an exception.
using (var ms = new MemoryStream())
{
using (var sw = new StreamWriter(ms))
using (var tw = new JsonTextWriter(sw))
{
if (ctx.Request.Path.Value.StartsWith("/api/v1/values"))
{
var series = ctx.Request.Query["series"];
var start = long.Parse(ctx.Request.Query["start"]);
var stop = long.Parse(ctx.Request.Query["stop"]);
var step = int.Parse(ctx.Request.Query["step"]);
serializer.Serialize(tw, await adapter.GetValuesAsync(series, start, stop, step));
}
else if (ctx.Request.Path.Value == "/api/v1/series")
{
serializer.Serialize(tw, await adapter.GetSeriesNamesAsync());
}
else if (ctx.Request.Path.Value == "/api/v1/predefined-pages")
{
await sw.WriteAsync(predefinedPages);
}
else if (ctx.Request.Path.Value == "/api/version")
{
serializer.Serialize(tw, Version);
}
else
{
ctx.Response.StatusCode = 501;
await sw.WriteLineAsync("not implemented");
}
}
var bs = ms.ToArray();
ctx.Response.Body.Write(bs, 0, bs.Length);
}
}