本文整理汇总了C#中IOwinContext.ReturnJson方法的典型用法代码示例。如果您正苦于以下问题:C# IOwinContext.ReturnJson方法的具体用法?C# IOwinContext.ReturnJson怎么用?C# IOwinContext.ReturnJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOwinContext
的用法示例。
在下文中一共展示了IOwinContext.ReturnJson方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallGrain
async Task CallGrain(IOwinContext context, IDictionary<string, string> parameters)
{
var grainTypeName = parameters["type"];
var grainId = parameters["id"];
var classPrefix = parameters.ContainsKey("classprefix") ? parameters["classprefix"] : null;
var grainMethodName = parameters["method"];
var grainType = GetGrainType(grainTypeName);
var grainFactory = GetGrainFactoryWithCache(grainTypeName);
var grain = GetGrain(grainType, grainFactory, grainId, classPrefix);
var grainMethod = this.grainMethodCache.GetOrAdd($"{grainTypeName}.{grainMethodName}", x => grainType.GetMethod(grainMethodName));
if (null == grainMethod) throw new MissingMethodException(grainTypeName, grainMethodName);
var grainMethodParams = GetGrainParameters(grainMethod, context).ToArray();
var result = await Dispatch(async () =>
{
var task = grainMethod.Invoke(grain, grainMethodParams) as Task;
await task;
// hack, as we can't cast task<int> to task<object>
var resultProperty = task.GetType().GetProperties().FirstOrDefault(x => x.Name == "Result");
if (null != resultProperty) return resultProperty.GetValue(task);
return null;
});
await context.ReturnJson(result);
}
示例2: GetDashboardCounters
async Task GetDashboardCounters(IOwinContext context, IDictionary<string, string> parameters)
{
var grain = this.ProviderRuntime.GrainFactory.GetGrain<IDashboardGrain>(0);
var result = await Dispatch(async () => {
return await grain.GetCounters();
});
await context.ReturnJson(result);
}
示例3: HandleRequest
async Task HandleRequest(IOwinContext context, Func<Task> func)
{
var result = this.Router.Match(context.Request.Path.Value);
if (null == result)
{
context.Response.StatusCode = 404;
return;
}
try
{
await result(context);
}
catch (Exception ex)
{
context.Response.StatusCode = 500;
await context.ReturnJson(ex);
}
}
示例4: GetRuntimeStats
async Task GetRuntimeStats(IOwinContext context, IDictionary<string, string> parameters)
{
var address = SiloAddress.FromParsableString(parameters["address"]);
var grain = this.ProviderRuntime.GrainFactory.GetGrain<IManagementGrain>(0);
var result = await Dispatch(async () =>
{
Dictionary<SiloAddress, SiloStatus> silos = await grain.GetHosts(true);
SiloStatus siloStatus;
if (silos.TryGetValue(address, out siloStatus))
{
return (await grain.GetRuntimeStatistics(new SiloAddress[] { address })).FirstOrDefault();
}
return null;
});
await context.ReturnJson(result);
}
示例5: GetSiloExtendedProperties
async Task GetSiloExtendedProperties(IOwinContext context, IDictionary<string, string> parameters)
{
var grain = this.ProviderRuntime.GrainFactory.GetGrain<ISiloGrain>(parameters["address"]);
var result = await Dispatch(async () =>
{
return await grain.GetExtendedProperties();
});
await context.ReturnJson(result);
}
示例6: Index
Task Index(IOwinContext context, IDictionary<string, string> parameters)
{
return context.ReturnJson(new { hello = "world" });
}