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


C# StackTrace.Select方法代码示例

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


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

示例1: ThrowWhenNoAppStartupsFixtureRuns

        private static void ThrowWhenNoAppStartupsFixtureRuns()
        {
            var frames = new StackTrace().GetFrames();

            if (frames != null && frames.Select(f => f.GetMethod().DeclaringType).Any(t => t == typeof(NoAppStartupsFixture)))
            {
                throw new Exception();
            }
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:9,代码来源:NoAppStartupsFixture.cs

示例2: RollbarTrace

        public RollbarTrace(Exception exception) {
            if (exception == null) {
                throw new ArgumentNullException("exception");
            }

            var frames = new StackTrace(exception, true).GetFrames() ?? new StackFrame[0];

            Frames = frames.Select(frame => new RollbarFrame(frame)).ToArray();
            Exception = new RollbarException(exception);
        }
开发者ID:Crisfole,项目名称:Valetude.Rollbar,代码行数:10,代码来源:RollbarTrace.cs

示例3: WriteLine

 public static void WriteLine(LogLevel level, string format, params object[] args)
 {
     var message = string.Format(format, args);
     if (level < Verbosity)
         return;
     var stackFrames = new StackTrace().GetFrames();
     if (stackFrames == null)
         return;
     var types = stackFrames.Select(frame => frame.GetMethod().DeclaringType);
     var type = types.First(t => t != typeof(Log) && t != null);
     Output [level](level, type.Name + ": " + message);
 }
开发者ID:jyunfan2015,项目名称:Calcifer,代码行数:12,代码来源:Log.cs

示例4: GetCurrentFeatureFile

        private static string GetCurrentFeatureFile()
        {
            try
            {
                var frames = new StackTrace(true).GetFrames();
                if (frames == null)
                    return null;

                return frames.Select(f => f.GetFileName()).FirstOrDefault(fn => fn != null && fn.EndsWith(".feature"));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex, "GetCurrentPositionText");
                return null;
            }
        }
开发者ID:gasparnagy,项目名称:CodeExample-SpecFlow-LivingHelp,代码行数:16,代码来源:ScenarioLoader.cs

示例5: SimpleExceptionDetail

        public SimpleExceptionDetail(System.Exception e, bool isIncludeStack = true)
            : this()
        {
            Message = e.Message;
            Type = e.GetType().FullName;

            if (!isIncludeStack) return;
            var frames = new StackTrace(e, true).GetFrames();

            if (frames == null || !frames.Any()) return;

            StacktraceDetails = frames.Select(r => new SimpleStacktraceDetail
            {
                File = r.GetFileName(),
                LineNumber = r.GetFileLineNumber(),
                Method = r.GetMethod().Name
            });
        }
开发者ID:pedrohugorm,项目名称:Gallifrey,代码行数:18,代码来源:SimpleExceptionDetail.cs

示例6: GetSocketPurpose

        private SocketPurpose GetSocketPurpose()
        {
            var stackFrames = new StackTrace(1).GetFrames();
            if (stackFrames
                    .FirstOrDefault(sf => sf.GetMethod().Name == CreateClusterMonitorSendingSocketMethod) != null)
            {
                return SocketPurpose.ClusterMonitorSendingSocket;
            }
            if (stackFrames
                    .FirstOrDefault(sf => sf.GetMethod().Name == CreateClusterMonitorSubscriptionSocketMethod) != null)
            {
                return SocketPurpose.ClusterMonitorSubscriptionSocket;
            }
            if (stackFrames
                    .FirstOrDefault(sf => sf.GetMethod().Name == CreateRouterCommunicationSocketMethod) != null)
            {
                return SocketPurpose.RouterCommunicationSocket;
            }

            throw new Exception($"Socket creation method is unexpected: {string.Join(" @ ", stackFrames.Select(sf => sf.ToString()))}");
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:21,代码来源:ClusterMonitorSocketFactory.cs

示例7: FromParameters

 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="message"></param>
 /// <param name="objects"></param>
 /// <param name="methodName"></param>
 /// <param name="sourceFilePath"></param>
 /// <param name="sourceLineNumber"></param>
 /// <returns></returns>
 public static LogInfo FromParameters(LogType type, string message, object[] objects,
                                      string methodName,
                                      string sourceFilePath,
                                      int sourceLineNumber)
 {
     var stackFrames = new StackTrace(true).GetFrames();
     return new LogInfo
                {
                    Date = DateTime.Now,
                    LogType = type,
                    Message = objects == null ? message : string.Format(message, objects),
                    Objects = objects,
                    StackTrace = stackFrames == null ? new string[0] : stackFrames.Select(s => s.ToString()).ToArray(),
                    CallerInfo = new CallerInfo
                                     {
                                         LineNumber = sourceLineNumber,
                                         MethodName = methodName,
                                         SourceFilePath = sourceFilePath
                                     }
                };
 }
开发者ID:Fel0ny,项目名称:QuickLog,代码行数:31,代码来源:LogInfo.cs


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