当前位置: 首页>>代码示例>>C#>>正文


C# IOwinContext.ReturnJson方法代码示例

本文整理汇总了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);
        }
开发者ID:OrleansContrib,项目名称:OrleansHttp,代码行数:30,代码来源:GrainController.cs

示例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);
        }
开发者ID:OrleansContrib,项目名称:OrleansDashboard,代码行数:9,代码来源:DashboardController.cs

示例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);
     }
 }
开发者ID:OrleansContrib,项目名称:OrleansDashboard,代码行数:18,代码来源:WebServer.cs

示例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);
        }
开发者ID:OrleansContrib,项目名称:OrleansDashboard,代码行数:20,代码来源:DashboardController.cs

示例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);
        }
开发者ID:OrleansContrib,项目名称:OrleansDashboard,代码行数:11,代码来源:DashboardController.cs

示例6: Index

 Task Index(IOwinContext context, IDictionary<string, string> parameters)
 {
     return context.ReturnJson(new { hello = "world" });
 }
开发者ID:richorama,项目名称:ra-db,代码行数:4,代码来源:Controller.cs


注:本文中的IOwinContext.ReturnJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。