本文整理汇总了C#中System.Web.HttpApplication.GetWarningStore方法的典型用法代码示例。如果您正苦于以下问题:C# HttpApplication.GetWarningStore方法的具体用法?C# HttpApplication.GetWarningStore怎么用?C# HttpApplication.GetWarningStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpApplication
的用法示例。
在下文中一共展示了HttpApplication.GetWarningStore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StandardResponse
public string StandardResponse(HttpApplication application, Guid requestId)
{
IDictionary<string, object> data;
if (!application.TryGetData(out data)) return "Error: No Glimpse Data Found";
var sb = new StringBuilder("{");
foreach (var item in data)
{
try
{
var dataString = JsSerializer.Serialize(item.Value);
sb.Append(string.Format("\"{0}\":{1},", item.Key, dataString));
}
catch(Exception ex)
{
var message = ex.Message;
if (ex is InvalidOperationException)
sb.Append(string.Format("\"{0}\":\"{1} : {2}<br/><span style='color:red;'>Please implement an IGlimpseConverter for the type mentioned above, or one of its base types, to fix this problem. More info on a better experience for this coming soon, keep an eye on <a href='http://getGlimpse.com' target='main'>getGlimpse.com</a></span>\",", item.Key, ex.GetType().Name, message));
else
sb.Append(string.Format("\"{0}\":\"{1} : {2}\",", item.Key, ex.GetType().Name, message));
}
}
//Add exceptions tab if needed
var exceptions = application.GetWarningStore();
if (exceptions.Count > 1)
{
var dataString = JsSerializer.Serialize(exceptions);
sb.Append(string.Format("\"{0}\":{1},", "Glimpse Warnings", dataString));
}
if (sb.Length > 1) sb.Remove(sb.Length - 1, 1);
sb.Append("}");
//var json = JsSerializer.Serialize(data); //serialize data to Json
var json = sb.ToString();
json = Sanitizer.Sanitize(json);
//if ajax request, render glimpse data to headers
if (application.IsAjax())
{
application.Response.AddHeader(GlimpseConstants.HttpHeader, requestId.ToString());
}
else
{
var html = string.Format(
@"<script type='text/javascript' id='glimpseData' data-glimpse-requestID='{1}'>var glimpse = {0};</script>", json, requestId);
html += @"<script type='text/javascript' id='glimpseClient' src='" + RootPath + "glimpseClient.js'></script>";
application.Response.Write(html);
}
return json;
}
示例2: ComposePlugins
private void ComposePlugins(HttpApplication context)
{
var directoryCatalog = new SafeDirectoryCatalog("bin");
Container = new CompositionContainer(directoryCatalog);
Container.ComposeParts(this, Responders);
var store = context.GetWarningStore();
foreach (var exception in directoryCatalog.Exceptions)
{
store.Add(new[] { exception.GetType().Name, exception.Message });
}
//wireup converters into serializer
Responders.RegisterConverters();
}