當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpApplication.GetWarningStore方法代碼示例

本文整理匯總了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;
        }
開發者ID:Talljoe,項目名稱:Glimpse,代碼行數:54,代碼來源:GlimpseResponders.cs

示例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();
            }
開發者ID:Talljoe,項目名稱:Glimpse,代碼行數:16,代碼來源:Module.cs


注:本文中的System.Web.HttpApplication.GetWarningStore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。