本文整理汇总了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)));
}
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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('\\');
}
}
示例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"));
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
示例14: Append
public override void Append(ErrorInfo error)
{
error.AddDetail(this.Name, "SecondKey", "SecondValue");
}