本文整理匯總了C#中Nancy.Responses.Negotiation.Negotiator.WithModel方法的典型用法代碼示例。如果您正苦於以下問題:C# Negotiator.WithModel方法的具體用法?C# Negotiator.WithModel怎麽用?C# Negotiator.WithModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nancy.Responses.Negotiation.Negotiator
的用法示例。
在下文中一共展示了Negotiator.WithModel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Handle
public void Handle(HttpStatusCode statusCode, NancyContext context)
{
var response = new Negotiator(context);
Error error = null;
if (context.Items.ContainsKey("OnErrorException"))
{
var exception = context.Items["OnErrorException"] as Exception;
error = new Error { ErrorMessage = exception.Message, FullException = exception.ToString() };
}
response.WithModel(new ErrorPageViewModel
{
Title = "Sorry, something went wrong",
Summary = error == null ? "An unexpected error occurred." : error.ErrorMessage,
Details = error == null ? null : error.FullException // TODO: Obey "ShowFullErrors" flag in config
}).WithStatusCode(statusCode).WithView("Error");
var errorresponse = responseNegotiator.NegotiateResponse(response, context);
string s = "";
context.Response = errorresponse;
}
示例2: GetNegotiator
private static Negotiator GetNegotiator(object routeResult, NancyContext context)
{
var negotiator = routeResult as Negotiator;
if (negotiator == null)
{
context.WriteTraceLog(sb => sb.AppendFormat("[DefaultRouteInvoker] Wrapping result of type {0} in negotiator\n", routeResult.GetType()));
negotiator = new Negotiator(context);
negotiator.WithModel(routeResult);
}
return negotiator;
}