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


C# ErrorInfo.AddDetail方法代码示例

本文整理汇总了C#中ErrorInfo.AddDetail方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorInfo.AddDetail方法的具体用法?C# ErrorInfo.AddDetail怎么用?C# ErrorInfo.AddDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorInfo的用法示例。


在下文中一共展示了ErrorInfo.AddDetail方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Append

 public override void Append(ErrorInfo errorInfo)
 {
     var memorystatusex = new MemoryStatusEx();
     if (NativeMethods.GlobalMemoryStatusEx(memorystatusex))
     {
         errorInfo.AddDetail(this.Name, "Total Memory", string.Format(CultureInfo.InvariantCulture, "{0} MB", memorystatusex.ullTotalPhys / (1024 * 1024)));
         errorInfo.AddDetail(this.Name, "Available Memory", string.Format(CultureInfo.InvariantCulture, "{0} MB", memorystatusex.ullAvailPhys / (1024 * 1024)));
     }
 }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:9,代码来源:MemoryAppender.cs

示例2: Append

        public override void Append(ErrorInfo error)
        {
            var pairs = new List<KeyValuePair<string, string>>();
            foreach (AssemblyPart ap in Deployment.Current.Parts)
            {
                StreamResourceInfo sri = Application.GetResourceStream(new Uri(ap.Source, UriKind.Relative));
                if (sri != null)
                {
                    Assembly assembly = new AssemblyPart().Load(sri.Stream);

                    pairs.Add(Message("Assembly", assembly.FullName));
                    pairs.Add(Message("ImageRuntimeVersion", assembly.ImageRuntimeVersion));

                    try
                    {
                        if (assembly.Location.Length != 0)
                        {
                            pairs.Add(Message("Location", assembly.Location));
                        }
                    }
                    catch
                    {
                    }
                }
            }
            error.AddDetail(this.Name, pairs);
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:27,代码来源:AssemblyAppender.cs

示例3: Append

        public override void Append(ErrorInfo errorInfo)
        {
            var sb = new StringBuilder();
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly assembly in assemblies)
            {
                sb.AppendLine(assembly.GetName().FullName);
            }
            sb.AppendLine();

            // Get file info
            foreach (Assembly assembly in assemblies)
            {
                bool flag = false;
                try
                {
                    if (assembly.Location.Length != 0)
                    {
                        sb.Append(FileVersionInfo.GetVersionInfo(assembly.Location).ToString());
                        flag = true;
                    }
                }
                catch(Exception)
                {
                }
                if (!flag)
                {
                    sb.Append(assembly.ToString());
                }
                sb.AppendLine();
            }
            errorInfo.AddDetail(this.Name, "", sb.ToString());
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:33,代码来源:AssemblyAppender.cs

示例4: Append

        public override void Append(ErrorInfo errorInfo)
        {
            Assembly assembly = errorInfo.GetType().Assembly;

            var pairs = new Dictionary<string, string>();
            pairs.Add("Date", DateTime.Now.ToString());
            pairs.Add("Culture", CultureInfo.CurrentCulture.Name);

            #if !SILVERLIGHT

            pairs.Add("User", string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", Environment.UserDomainName, Environment.UserName).Trim('\\'));
            pairs.Add("Machine Name", Environment.MachineName);
            pairs.Add("App Start Time", Process.GetCurrentProcess().StartTime.ToLocalTime().ToString(CultureInfo.InvariantCulture));
            pairs.Add("App Up Time", (DateTime.Now - Process.GetCurrentProcess().StartTime.ToLocalTime()).ToString());
            pairs.Add("Worker process", GetWorkerProcess());
            pairs.Add("AppDomain", AppDomainDetail(AppDomain.CurrentDomain));
            pairs.Add("Deployment", (assembly.GlobalAssemblyCache) ? "GAC" : "bin");

            #endif
            pairs.Add("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture));
            pairs.Add("Full Name", new AssemblyName(assembly.FullName).FullName);
            pairs.Add("Operating System Version", Environment.OSVersion.ToString());
            pairs.Add("Common Language Runtime Version", Environment.Version.ToString());
            pairs.Add("Elmah.Everywhere Version", new AssemblyName(typeof(Diagnostics.ExceptionHandler).Assembly.FullName).Version.ToString());

            errorInfo.AddDetail(this.Name, pairs);
        }
开发者ID:onurak,项目名称:vinco-logging-toolkit,代码行数:27,代码来源:DetailAppender.cs

示例5: Append

        public override void Append(ErrorInfo errorInfo)
        {
            var pairs = new Dictionary<string, string>();
            pairs.Add("CellularMobileOperator", DeviceNetworkInformation.CellularMobileOperator);
            pairs.Add("IsCellularDataEnabled", DeviceNetworkInformation.IsCellularDataEnabled.ToString());
            pairs.Add("IsCellularDataRoamingEnabled", DeviceNetworkInformation.IsCellularDataRoamingEnabled.ToString());
            pairs.Add("IsNetworkAvailable", DeviceNetworkInformation.IsNetworkAvailable.ToString());
            pairs.Add("IsWiFiEnabled", DeviceNetworkInformation.IsWiFiEnabled.ToString());

            errorInfo.AddDetail(this.Name, pairs);
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:11,代码来源:DeviceNetworkAppender.cs

示例6: Append

 public override void Append(ErrorInfo error)
 {
     if (error.Properties != null && error.Properties.Count > 0)
     {
         var pairs = new Dictionary<string, string>();
         foreach (var key in error.Properties.Keys)
         {
             pairs.Add(key, error.Properties[key].ToString());
         }
         error.AddDetail(this.Name, pairs);
     }
 }
开发者ID:RoseMadder,项目名称:vinco-logging-toolkit,代码行数:12,代码来源:PropertiesAppender.cs

示例7: GetInfo

        private static ErrorInfo GetInfo()
        {
            var info = new ErrorInfo(new Exception("Test Exception"))
                       {
                           ApplicationName = "ApplicationName",
                           Host = "Host",
                           ErrorType = "ErrorType",
                           Source = "Source",
                           Message = "Message",
                           Detail = "Detail",
                           Date = DateTime.Now,
                           User = "User",
                           StatusCode = 1000
                       };

            info.AddDetail("Cookies", "Key", "Value");
            info.AddDetail("Form", "Key", "Value");
            info.AddDetail("QueryString", "Key", "Value");
            info.AddDetail("ServerVariables", "Key", "Value");

            return info;
        }
开发者ID:onurak,项目名称:vinco-logging-toolkit,代码行数:22,代码来源:ElmahErrorHelperTest.cs

示例8: Append

        public override void Append(ErrorInfo errorInfo)
        {
            HttpContextBase httpContext = GetContext();

            if (httpContext != null)
            {
                var pairs = new Dictionary<string, string>();

                pairs.Add("Web server", GetWebServer());
                pairs.Add("Integrated pipeline", HttpRuntime.UsingIntegratedPipeline.ToString());

                errorInfo.AddDetail(this.Name, pairs);

                HttpRequestBase httpRequest = httpContext.Request;

                errorInfo.AddDetail("ServerVariables", ToDictionary(httpRequest.ServerVariables));
                errorInfo.AddDetail("QueryString", ToDictionary(httpRequest.QueryString));
                errorInfo.AddDetail("Form", ToDictionary(httpRequest.ServerVariables));
                errorInfo.AddDetail("Cookies", ToDictionary(CopyCollection(httpRequest.Cookies)));

                HttpException httpException = errorInfo.Exception as HttpException;
                if (httpException != null)
                {
                    errorInfo.StatusCode = httpException.GetHttpCode();
                }

                IPrincipal webUser = httpContext.User;
                if (webUser != null && webUser.Identity.Name.Length > 0)
                {
                    errorInfo.User = webUser.Identity.Name;
                }
            }

            if (string.IsNullOrWhiteSpace(errorInfo.User))
            {
                errorInfo.User = string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", Environment.UserDomainName, Environment.UserName).Trim('\\');
            }
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:38,代码来源:HttpAppender.cs

示例9: BuildMessage_Appends_Details

        public void BuildMessage_Appends_Details()
        {
            // Arrange
            ErrorInfo error = new ErrorInfo(new Exception());
            var pair = new List<KeyValuePair<string, string>>();
            pair.Add(new KeyValuePair<string, string>("Key", "Value"));

            error.AddDetail("Append Test", pair);

            // Act
            string detail = error.BuildMessage();

            // Assert
            Assert.True(detail.Contains("Append Test"));
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:15,代码来源:ErrorInfoTest.cs

示例10: AddDetail_Test

        public void AddDetail_Test()
        {
            // Arrange
            ErrorInfo error = new ErrorInfo();

            error.AddDetail("Test", "Key", "Value");

            // Act
            DetailInfo detail = error.ErrorDetails.First();

            // Assert
            Assert.Equal("Test", detail.Name);
            Assert.Equal("Key", detail.Items[0].Key);
            Assert.Equal("Value", detail.Items[0].Value);
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:15,代码来源:ErrorInfoTest.cs

示例11: Append

        public override void Append(ErrorInfo errorInfo)
        {
            var pairs = new Dictionary<string, string>();
            pairs.Add("ApplicationCurrentMemoryUsage", Utility.FormatBytes(DeviceStatus.ApplicationCurrentMemoryUsage));
            pairs.Add("ApplicationMemoryUsageLimit", Utility.FormatBytes(DeviceStatus.ApplicationMemoryUsageLimit));
            pairs.Add("ApplicationPeakMemoryUsage", Utility.FormatBytes(DeviceStatus.ApplicationPeakMemoryUsage));
            pairs.Add("DeviceFirmwareVersion", DeviceStatus.DeviceFirmwareVersion);
            pairs.Add("DeviceHardwareVersion", DeviceStatus.DeviceHardwareVersion);
            pairs.Add("DeviceManufacturer", DeviceStatus.DeviceManufacturer);
            pairs.Add("DeviceName", DeviceStatus.DeviceName);
            pairs.Add("DeviceTotalMemory", Utility.FormatBytes(DeviceStatus.DeviceTotalMemory));
            pairs.Add("IsKeyboardDeployed", DeviceStatus.IsKeyboardDeployed.ToString());
            pairs.Add("IsKeyboardPresent", DeviceStatus.IsKeyboardPresent.ToString());
            pairs.Add("PowerSource", DeviceStatus.PowerSource.ToString());
            pairs.Add("DeviceType", Environment.DeviceType.ToString());

            errorInfo.AddDetail(this.Name, pairs);
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:18,代码来源:DeviceStatusAppender.cs

示例12: Append

        public override void Append(ErrorInfo errorInfo)
        {
            var sb = new StringBuilder();

            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly assembly in assemblies)
            {
                sb.AppendLine(assembly.GetName().FullName);
            }
            sb.AppendLine();

            foreach (dynamic assembly in assemblies)
            {
                var assemblyName = new AssemblyName(assembly.FullName);

                sb.AppendLine(string.Format("File:                  {0}", assembly.Location));
                sb.AppendLine(string.Format("FullName:              {0}", assembly.FullName));
                sb.AppendLine(string.Format("ImageRuntimeVersion:   {0}", assembly.ImageRuntimeVersion));
                sb.AppendLine(string.Format("Version:               {0}", assemblyName.Version));
                sb.AppendLine(string.Format("IsDynamic:             {0}", assembly.IsDynamic));
                sb.AppendLine();
            }
            errorInfo.AddDetail(this.Name, "", sb.ToString());
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:24,代码来源:AssemblyAppender.cs

示例13: DeserializeXmlToDetail

 private static void DeserializeXmlToDetail(ErrorInfo info, XElement element)
 {
     foreach (var detail in element.Elements())
     {
         var pairs = new List<KeyValuePair<string, string>>();
         foreach (var item in detail.Elements())
         {
             var pair = new KeyValuePair<string, string>(GetAttributeValue(item, "Name"), GetAttributeValue(item, "Value"));
             pairs.Add(pair);
         }
         info.AddDetail(GetAttributeValue(detail, "Name"), pairs);
     }
 }
开发者ID:RoseMadder,项目名称:vinco-logging-toolkit,代码行数:13,代码来源:Utility.cs

示例14: Append

 public override void Append(ErrorInfo error)
 {
     error.AddDetail(this.Name, "SecondKey", "SecondValue");
 }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:4,代码来源:ErrorInfoTest.cs


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