コード例 #1
1
ファイル: ErrorHandlerHelper.cs プロジェクト: JMnITup/SMEX
        //Can only be called inside a service
        public static void PromoteException(Exception error,MessageVersion version,ref Message fault)
        {
            StackFrame frame = new StackFrame(1);

             Type serviceType = frame.GetMethod().ReflectedType;
             PromoteException(serviceType,error,version,ref fault);
        }
コード例 #2
0
ファイル: MonitoringManager.cs プロジェクト: Mocahteam/FYFY
        /// <summary>
        ///     Get next actions to perform in order to reach targeted game action.
        /// </summary>
        /// <param name="family">The monitored Family on which you want reach action.</param>
        /// <param name="targetedActionName">Action name you want to reach, this name has to match with a transition defined into associated Petri Net  of the "family" parameter <see cref="ComponentMonitoring.PnmlFile"/> The special key word "##playerObjectives##" enable to target all player objective actions defined inside full Petri Net from which the monitor is part of (in this special case, "linksConcerned" parameter will be ignore).</param>
        /// <param name="maxActions">Maximum number of actions returned.</param>
        /// <param name="linksConcerned">links label concerned by this action. You can leave empty if only "*" operators are used in logic expression. Must be defined if logic expression associated to the action include "+" operators. For instance, if logic expression is "(l0+l1)*l3" you have to indicate which links to use to look for the trace: l0 and l3 OR l1 and l3 => <code>MonitoringManager.getNextActionToReach(..., "l0", "l3");</code> OR <code>MonitoringManager.getNextActionToReach(..., "l1", "l3");</code></param>
        /// <returns>List of Pairs including a ComponentMonitoring and its associated game action useful to reach the targeted action, the number of actions returned is less or equal to maxActions parameters.</returns>
        public static List <KeyValuePair <ComponentMonitoring, string> > getNextActionsToReach(Family family, string targetedActionName, int maxActions, params string[] linksConcerned)
        {
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true);                                                      // get caller stackFrame with informations
            string exceptionStackTrace = "(at " + stackFrame.GetFileName() + ":" + stackFrame.GetFileLineNumber().ToString() + ")";                     // to point where this function was called

            if (MonitoringManager.Instance == null)
            {
                throw new TraceAborted("No MonitoringManager found. You must add MonitoringManager component to one of your GameObject first (the Main_Loop for instance).", null);
            }

            FamilyMonitoring fm = MonitoringManager.Instance.getFamilyMonitoring(family);

            if (fm == null)
            {
                throw new TraceAborted("No monitor found for this family", null);
            }

            string internalName = targetedActionName;

            if (!targetedActionName.Equals("##playerObjectives##"))
            {
                internalName = fm.getInternalName(targetedActionName, exceptionStackTrace, true, linksConcerned);
            }
            if (fm.fullPnSelected >= MonitoringManager.Instance.PetriNetsName.Count)
            {
                fm.fullPnSelected = 1;
            }
            string pnName = MonitoringManager.Instance.PetriNetsName[fm.fullPnSelected];

            return(MonitoringManager.getNextActionsToReach(pnName, internalName, maxActions));
        }
コード例 #3
0
ファイル: tracing.cs プロジェクト: Zelxin/RPiKeg
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Method to trace the current call with an additional message</summary> 
        /// <param name="msg"> msg string to display</param>
        /// <param name="startFrame">the startFrame to uses</param>
        /// <param name="indent"> intendation</param>
        //////////////////////////////////////////////////////////////////////
        [Conditional("TRACE")] static private void TraceCall(string msg, StackFrame startFrame, int indent)
        {
            // puts out the callstack and the msg
            try
            {
                if (startFrame != null)
                {
                    StringBuilder  outMsg = new StringBuilder();
                    MethodBase  method = startFrame.GetMethod();

                    while (indent-- > 0)
                        outMsg.Append("    ");

                    outMsg.Append("--> " + method.DeclaringType.Name + "." + method.Name + "()");

                    if (!String.IsNullOrEmpty(msg))
                        outMsg.Append(": " + msg);

                    Tracing.TraceMsg(outMsg.ToString());
                }
                else
                {
                    Tracing.TraceMsg("Method Unknown: " + msg);
                }
                Trace.Flush();
            }
            catch 
            {
                Tracing.TraceMsg(msg);
            }
        }
コード例 #4
0
ファイル: NpgsqlLogManager.cs プロジェクト: Emill/Npgsql
        // Copied from NLog
        static string GetClassFullName()
        {
            string className;
            Type declaringType;
            int framesToSkip = 2;

            do {
#if SILVERLIGHT
                StackFrame frame = new StackTrace().GetFrame(framesToSkip);
#else
                StackFrame frame = new StackFrame(framesToSkip, false);
#endif
                MethodBase method = frame.GetMethod();
                declaringType = method.DeclaringType;
                if (declaringType == null) {
                    className = method.Name;
                    break;
                }

                framesToSkip++;
                className = declaringType.FullName;
            } while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase));

            return className;
        }
コード例 #5
0
    private static void LogMessage(string tag, int stackIndex, string arguments, string message)
    {
#if DEBUG
        var frame = new System.Diagnostics.StackFrame(stackIndex, true);

        var thread     = System.Threading.Thread.CurrentThread;
        var threadInfo = "<" + thread.ManagedThreadId.ToString("000") + (string.IsNullOrEmpty(thread.Name) ? "" : ("=" + thread.Name)) + ">";
#if GG_PLATFORM_IOS
        var dateInfo = "";
#else
        var dateInfo = "[" + DateTime.Now.ToString("HH:mm:ss,fff") + "]";
#endif
        var backrefInfo = new string(' ', 32) + " in " + frame.GetFileName() + ":" + frame.GetFileLineNumber();
        var methodInfo  = frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name + "(" + arguments + ")";

        var msg = threadInfo + " " + dateInfo + " " + methodInfo + " " + message + " " + backrefInfo;

#if GG_PLATFORM_ANDROID
        Android.Util.Log.Debug(tag, msg);
#elif GG_PLATFORM_IOS
        Console.WriteLine(tag + " " + msg);
#else
        Debug.WriteLine(tag + " " + msg);
#endif
#endif // DEBUG
    }
コード例 #6
0
        public string combine_paths(string leftItem, params string[] rightItems)
        {
            if (leftItem == null)
            {
                var methodName = string.Empty;
                var stackFrame = new System.Diagnostics.StackFrame(1);
                if (stackFrame != null)
                {
                    methodName = stackFrame.GetMethod().Name;
                }
                throw new ApplicationException("Path to combine cannot be empty. Tried to combine null with '{0}'.{1}".format_with(string.Join(",", rightItems), string.IsNullOrWhiteSpace(methodName) ? string.Empty : " Method called from '{0}'".format_with(methodName)));
            }

            var combinedPath = Platform.get_platform() == PlatformType.Windows ? leftItem : leftItem.Replace('\\', '/');

            foreach (var rightItem in rightItems)
            {
                if (rightItem.Contains(":"))
                {
                    throw new ApplicationException("Cannot combine a path with ':' attempted to combine '{0}' with '{1}'".format_with(rightItem, combinedPath));
                }

                var rightSide = Platform.get_platform() == PlatformType.Windows ? rightItem : rightItem.Replace('\\', '/');
                if (rightSide.StartsWith(Path.DirectorySeparatorChar.to_string()) || rightSide.StartsWith(Path.AltDirectorySeparatorChar.to_string()))
                {
                    combinedPath = Path.Combine(combinedPath, rightSide.Substring(1));
                }
                else
                {
                    combinedPath = Path.Combine(combinedPath, rightSide);
                }
            }

            return(combinedPath);
        }
コード例 #7
0
        /// <summary>
        /// Throws a new exception with the name of the parent function and value of the HR
        /// </summary>
        /// <param name="hr">Error # to include</param>
        internal void ThrowExceptionHere(int hr)
        {
            StackTrace stackTrace = new StackTrace();

            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(1);
            throw new Exception(String.Format("Error in {0}: {1}", stackFrame.GetMethod().Name, hr));
        }
コード例 #8
0
        /// <summary>
        /// Gets a <see cref="ILog"/> instance named after the caller's declaring or reflected type.
        /// </summary>
        public static ILog GetCurrentClassLogger()
        {
            var caller = new StackFrame(1, false).GetMethod();
            var name = (caller.DeclaringType ?? caller.ReflectedType ?? typeof(UnknownLogger)).FullName;

            return Instance.CreateLogger(name);
        }
コード例 #9
0
 public LgContextException(string condition, System.Diagnostics.StackFrame sf = null, string stackTraceString = null)
     : base(condition)
 {
     // Keep the stackframe so the editor can open the file to the right line!
     this.Sf = sf;
     this.StackTraceString = stackTraceString;
 }
コード例 #10
0
        public static string GetCurrentMethod()
        {
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
            System.Diagnostics.StackFrame sf = st.GetFrame(1);

            return(sf.GetMethod().Name);
        }
コード例 #11
0
 public void OnAuthentication(AuthenticationContext filterContext)
 {
     System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
     System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
     log.Debug("Start: " + methodBase.Name);
     try
     {
         if (UserLogin.ValidateUserRequest())
         {
             filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "Login" }, { "area", "" } });
         }
         else
         {
             string context = filterContext.Controller.ControllerContext.HttpContext.Request.Path;
             int UserID = Convert.ToInt32(filterContext.HttpContext.Session["UserID"]);
             string Role = MenuBinding.CheckURlAndGetUserRole(context, UserID);
             if (Role == null)
             {
                 filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "Index" }, { "area", "" } });
             }
             filterContext.Controller.ViewBag.Role = Role;
         }
     }
     catch (Exception ex)
     {
         log.Error("Error: " + ex);
     }
     log.Debug("End: " + methodBase.Name);
 }
コード例 #12
0
        private static string GetExpectedOutputReaderFromAttribute(StackFrame stackFrame)
        {
            var i = 3;
            do
            {
                var callingMethod = stackFrame.GetMethod();
                if (callingMethod.MethodImplementationFlags != MethodImplAttributes.IL)
                    return null;

                var expectedOutputAttribute = (ExpectedOutputAttribute)callingMethod.GetCustomAttributes(typeof(ExpectedOutputAttribute), false).LastOrDefault();
                if (expectedOutputAttribute != null)
                {
                    var reflectedType = callingMethod.ReflectedType;

                    var expectedOutputsFileName =
                        string.IsNullOrEmpty(expectedOutputAttribute.FileName) ?
                        reflectedType.Name + "ExpectedOutputs.txt" :
                        expectedOutputAttribute.FileName;

                    return GetExpectedOutputReader(callingMethod.ReflectedType, callingMethod.Name, expectedOutputsFileName);
                }
                
                stackFrame = new StackFrame(i++);
            } while (true);
        }
コード例 #13
0
        public void Enrich(LogEvent e, out string propertyName, out object propertyValue)
        {
            var frame = new StackFrame(4);   //warning! this can change after refactoring

             propertyName = "method";

             MethodBase method = frame.GetMethod();
             var sb = new StringBuilder();

             sb.Append(method.DeclaringType.FullName);
             sb.Append(".");
             sb.Append(method.Name);
             sb.Append("(");
             bool isFirst = true;
             foreach(ParameterInfo p in method.GetParameters())
             {
            if (!isFirst)
            {
               sb.Append(", ");
            }
            else
            {
               isFirst = false;
            }
            sb.Append(p.ParameterType.Name);
            sb.Append(" ");
            sb.Append(p.Name);
             }
             sb.Append(")");

             propertyValue = sb.ToString();
        }
コード例 #14
0
    private static string callerMethod(int i)
    {
        System.Diagnostics.StackFrame frame = new System.Diagnostics.StackFrame(i + 1);
        var method = frame.GetMethod();

        return(method.DeclaringType.ToString() + " : " + method.Name);
    }
コード例 #15
0
ファイル: Worker.cs プロジェクト: MGramolini/Trinity
        /// <summary>
        /// Run code in a new worker thread. WorkerDelegate should return true to end, false to repeat.
        /// </summary>
        /// <param name="worker">Delegate to be run</param>
        /// <param name="waitTime"></param>
        public static void Start(Func<bool> worker, int waitTime = 50)
        {
            if (IsRunning)
                return;

            WaitTime = waitTime;

            var frame = new StackFrame(1);
            var method = frame.GetMethod();
            var type = method.DeclaringType;
            var ns = type != null ? type.Namespace : string.Empty;

            _worker = worker;
            _thread = new Thread(SafeWorkerDelegate)
            {
                Name = string.Format("Worker: {0}.{1}", ns, type),
                IsBackground = true,
                Priority = ThreadPriority.BelowNormal,
            };

            Logger.LogDebug("Starting {0} Thread Id={1}", _thread.Name, _thread.ManagedThreadId);

            _working = true;
            _thread.Start();

            OnStarted.Invoke();
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: Appdevcount/MCConsoleTEST
        public void reflectiontest1()
        {
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            System.Reflection.MethodBase  methodBase = stackFrame.GetMethod();
            Console.WriteLine(methodBase.Name); // Displays "WhatsmyName"
            try
            {
                throw new Exception();
            }
            catch
            {
                System.Diagnostics.StackFrame stackFrameex = new System.Diagnostics.StackFrame();
                System.Reflection.MethodBase  methodBaseex = stackFrame.GetMethod();
                Console.WriteLine(methodBaseex.Name); // Displays "WhatsmyName"
            }
            try
            {
                Program pe = new Program();
                pe.reflectiontest2();//
            }
            catch
            {
                System.Diagnostics.StackFrame stackFrameex = new System.Diagnostics.StackFrame();
                System.Reflection.MethodBase  methodBaseex = stackFrame.GetMethod();
                Console.WriteLine(methodBaseex.Name); // Displays "WhatsmyName"

                StackTrace stackTracep = new StackTrace();
                StackFrame stackFramep = stackTracep.GetFrame(1);
                MethodBase methodBasep = stackFrame.GetMethod();
                // Displays "WhatsmyName"
                Console.WriteLine(" Parent Method Name {0} ", methodBasep.Name);
            }
        }
コード例 #17
0
ファイル: CallSiteCache.cs プロジェクト: niik/RxSpy
        public static CallSite Get(int skipFrames)
        {
            // Account for ourselves
            skipFrames++;

            if (_stackFrameFast == null)
            {
                // This is terribad, this session is going to be soooo sloooooooooooow.
                // This will eventually happen when the .NET framework authors
                // excercise their right to change the private implementation we're
                // depending on.
                // Fall back to expensive full frame

                return new CallSite(new StackFrame(skipFrames, true));
            }

            // Don't exactly know why we need to skip 2 and not 1 here.
            // I suspect expression tree trickery.
            var key = _stackFrameFast(skipFrames + 2);

            CallSite cached;

            if (_cache.TryGetValue(key, out cached))
                return cached;

            var frame = new StackFrame(skipFrames, true);

            var callSite = new CallSite(frame);

            return _cache.GetOrAdd(key, callSite);
        }
コード例 #18
0
ファイル: CommonMemberFilter.cs プロジェクト: CAPCHIK/roslyn
        public override bool Include(StackFrame frame)
        {
            var method = frame.GetMethod();
            if (IsHiddenMember(method))
            {
                return false;
            }

            var type = method.DeclaringType;

            // TODO (https://github.com/dotnet/roslyn/issues/5250): look for other types indicating that we're in Roslyn code
            if (type == typeof(CommandLineRunner))
            {
                return false;
            }

            // Type is null for DynamicMethods and global methods.
            // TODO (tomat): we don't want to include awaiter helpers, shouldn't they be marked by DebuggerHidden in FX?
            if (type == null || IsTaskAwaiter(type) || IsTaskAwaiter(type.DeclaringType))
            {
                return false;
            }

            return true;
        }
コード例 #19
0
ファイル: ScopeLogger.cs プロジェクト: alejandraa/TaskMQ
        public static ScopeLogger GetClassLogger(ILogTape baseLogger = null, int framesToSkip = 1)
        {
            // extracted from: https://github.com/NLog
            string loggerName;
            Type declaringType;

            do
            {
                StackFrame frame = new StackFrame(framesToSkip, false);

                var method = frame.GetMethod();
                declaringType = method.DeclaringType;
                if (declaringType == null)
                {
                    loggerName = method.Name;
                    break;
                }

                framesToSkip++;
                loggerName = declaringType.FullName;
            } while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase));

            if (baseLogger == null)
                baseLogger = commonLogTape;

            return new ScopeLogger(loggerName, baseLogger);
        }
コード例 #20
0
        private void AddToLog(string msg, bool isAnError, UnityEngine.Object obj)
        {
            StackTrace stackTrace = new StackTrace(2, true);

            System.Diagnostics.StackFrame frame = stackTrace.GetFrame(0);
            this.LogMessage(msg, frame.GetFileName(), frame.GetFileLineNumber(), obj, isAnError);
        }
コード例 #21
0
        /// <summary>
        /// Parse the property value
        /// </summary>
        /// <param name="n">XmlElement object for the property value obtained from the Mingle API</param>
        public void Parse(XmlElement n)
        {
            var me = new StackFrame().GetMethod().Name;
            TraceLog.WriteLine(me, "Entering...");

            foreach (XmlElement e in n.ChildNodes.Cast<XmlElement>())
            {
                switch (e.Name)
                {
                    case "id":
                        Id = Convert.ToInt32(e.InnerText, CultureInfo.InvariantCulture);
                        break;

                    case "value":
                        Value = string.Format(CultureInfo.InvariantCulture, e.InnerText);
                        break;

                    case "color":
                        Color = string.Format(CultureInfo.InvariantCulture, e.InnerText);
                        break;

                    case "position":
                        Position = Convert.ToInt32(e.InnerText, CultureInfo.InvariantCulture);
                        break;
                }
            }

            TraceLog.WriteLine(me, "Entering...");
        }
コード例 #22
0
ファイル: LogData.cs プロジェクト: JChan106/HACKPOLY16
 internal LogData (LogLevel level, StackFrame caller, string message)
 {
   _level = level;
   _caller = caller;
   _message = message ?? String.Empty;
   _date = DateTime.Now;
 }
コード例 #23
0
ファイル: LogProvider.cs プロジェクト: Leafney/Kalman.Studio
		/// <summary>
		/// 获取日志记录器(为当前类找出匹配的日志记录器)
		/// </summary>
		public ILogger GetCurrentClassLogger()
		{
			var frame = new StackFrame(2);  //调用日志记录器的类所在的堆栈帧
			Type classType = frame.GetMethod().ReflectedType;

			// 查找配置中所有匹配的日志记录器
			IList<ILogger> loggers = FindLoggers(classType);
			if (loggers.Count == 0)
			{
				return LogManager.NullLogger;
			}
			if (loggers.Count == 1)
				return loggers[0];

			MultiLogger logger = new MultiLogger(loggers);
			LogLevel minLevel = LogLevel.Fatal;
			foreach (var logger1 in loggers)
			{
				if (logger1.MinLevel < minLevel)
					minLevel = logger1.MinLevel;
			}

			logger.LoadConfig(new LoggerConfig{MinLevel = minLevel, Name = "MultiLogger"});
			return logger;
		}
コード例 #24
0
        private static void ShowVsAssert(string stackTrace, StackFrame frame, string message, string detailMessage) {
            int[] disable = new int[1];
            try {
                string detailMessage2;
                
                if (detailMessage == null)
                    detailMessage2 = stackTrace; 
                else
                    detailMessage2 = detailMessage + Environment.NewLine + stackTrace;                
                string fileName = (frame == null) ? string.Empty : frame.GetFileName();
                if (fileName == null) {
                    fileName = string.Empty;
                }

                int lineNumber = (frame == null) ? 0 : frame.GetFileLineNumber();
                int returnCode = VsAssert(detailMessage2, message, fileName, lineNumber, disable);
                if (returnCode != 0) {
                    if (!System.Diagnostics.Debugger.IsAttached) {
                        System.Diagnostics.Debugger.Launch();
                    }
                    System.Diagnostics.Debugger.Break();
                }
                if (disable[0] != 0)
                    ignoredAsserts[MakeAssertKey(fileName, lineNumber)] = null;
            }
            catch (Exception) {
                vsassertPresent = false;
            }
        }
コード例 #25
0
ファイル: Logger.cs プロジェクト: ananse23/EsriWPF
 public static void Log(string message)
 {
     var trace = new StackFrame(1);
     var methodBase = trace.GetMethod();
     var type = methodBase.DeclaringType;
     LogManager.GetLogger(type).Info(message);
 }
コード例 #26
0
ファイル: Common.cs プロジェクト: rodibidably/git-tools
 // Constructors
 // Methods
 public void Trace(string message, bool addStackFrame = true)
 {
     try
     {
         if (_DebugMode)
         {
             string msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": ";
             if (addStackFrame)
             {
                 System.Diagnostics.StackFrame stackframe = new System.Diagnostics.StackFrame(1);
                 msg += stackframe.GetMethod().ReflectedType.FullName + "." + stackframe.GetMethod().Name + " - ";
             }
             msg += message;
             if (message == "")
             {
                 msg = System.Environment.NewLine + msg;
             }
             if (string.IsNullOrEmpty(_DebugLocation))
             {
                 _DebugLocation = Path.GetTempPath();
             }
             StreamWriter tw = new StreamWriter(_DebugLocation + "\\\\iApplications.log", true);
             tw.WriteLine(msg);
             tw.Close();
         }
     }
     catch (Exception ex)
     {
         ErrHandle(ex, false);
     }
 }
コード例 #27
0
ファイル: StaticHelper.cs プロジェクト: pars87/Catel
        public static Type GetCallingType()
        {
            if (EnvironmentHelper.IsProcessHostedByTool)
            {
                return typeof(object);
            }


//#if NETFX_CORE
//            var type = typeof(object);
//#else
//            var stackTrace = StackTraceHelper.GetStackTrace();
//            var stackFrame = stackTrace.GetFrame(2);
//            var type = stackFrame.GetMethod().DeclaringType;
//#endif

#if NET
            var frame = new StackFrame(2, false);
            var type = frame.GetMethod().DeclaringType;
#elif NETFX_CORE
            var type = typeof(object);
#else
            var frame = new StackTrace().GetFrame(2);
            var type = frame.GetMethod().DeclaringType;
#endif

            return type;
        }
コード例 #28
0
        public string GetLastLogin(string id)
        {
            var s = "";

            try
            {
                var query = string.Format("SELECT * from WP_GAA_Users where Unique_ID like '{0}';", id);

                using (var connection = new MySqlConnection(ConnectionString))
                {
                    connection.Open();
                    using (var cmd = new MySqlCommand(query, connection))
                    {
                        using (var r = cmd.ExecuteReader())
                        {
                            while (r.Read())
                            {
                                var loginOrdinal = r.GetOrdinal("Last_Used");
                                if (r.IsDBNull(loginOrdinal)) s = DateTime.MinValue.ToString();
                                else s = r.GetString("Last_Used");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var sf = new StackFrame();
                var methodBase = sf.GetMethod();
                Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString());
            }

            return s;
        }
コード例 #29
0
        /// <summary>
        /// Converts a System.Diagnostics.StackFrame to a Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryTypes.StackFrame.
        /// </summary>
        internal static IStackFrame GetStackFrame(System.Diagnostics.StackFrame stackFrame, int frameId)
        {
            var convertedStackFrame = new Telemetry.DataContract.StackFrame()
            {
                level = frameId
            };

            var    methodInfo = stackFrame.GetMethod();
            string fullName;

            if (methodInfo.DeclaringType != null)
            {
                fullName = methodInfo.DeclaringType.FullName + "." + methodInfo.Name;
            }
            else
            {
                fullName = methodInfo.Name;
            }

            convertedStackFrame.method   = fullName;
            convertedStackFrame.assembly = methodInfo.Module.Assembly.FullName;
            convertedStackFrame.fileName = stackFrame.GetFileName();

            // 0 means it is unavailable
            int line = stackFrame.GetFileLineNumber();

            if (line != 0)
            {
                convertedStackFrame.line = line;
            }

            return(convertedStackFrame);
        }
コード例 #30
0
ファイル: Logger.cs プロジェクト: eriser/alphaSynth
        private static void Log(LogLevel logLevel, string msg)
        {
            if (logLevel < LogLevel) return;

            StackFrame frame = new StackFrame(2, true);
            var method = frame.GetMethod();
            var lineNumber = frame.GetFileLineNumber();

            var color = Console.ForegroundColor;
            switch (logLevel)
            {
                case LogLevel.None:
                    break;
                case LogLevel.Debug:
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    break;
                case LogLevel.Info:
                    Console.ForegroundColor = ConsoleColor.Gray;
                    break;
                case LogLevel.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;
                case LogLevel.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
            }

            Console.WriteLine("{0}.{1}:{2} - {3}", method.DeclaringType.FullName, method.Name, lineNumber, msg);
            Console.ForegroundColor = color;
        }
コード例 #31
0
            private StackFrameInfo(StackFrame frame)
            {
                SetStackMeta(frame);

                if (frame.GetILOffset() == -1)
                {
                    return;
                }

                string filename = null;
                try
                {
                    filename = frame.GetFileName();
                    if (filename != null)
                    {
                        LineNumber = frame.GetFileLineNumber();
                    }
                }
                catch (SecurityException)
                {

                }

                FileName = filename;
            }
コード例 #32
0
ファイル: MiniWeb.cs プロジェクト: robashton/EventStore
 public static string GetWebRootFileSystemDirectory(string debugPath = null)
 {
     string fileSystemWebRoot = null;
     try
     {
         if (!string.IsNullOrEmpty(debugPath))
         {
             var sf = new StackFrame(0, true);
             var fileName = sf.GetFileName();
             var sourceWebRootDirectory = string.IsNullOrEmpty(fileName)
                                              ? ""
                                              : Path.GetFullPath(Path.Combine(fileName, @"..\..\..", debugPath));
             fileSystemWebRoot = Directory.Exists(sourceWebRootDirectory)
                                     ? sourceWebRootDirectory
                                     : AppDomain.CurrentDomain.BaseDirectory;
         }
         else
         {
             fileSystemWebRoot = AppDomain.CurrentDomain.BaseDirectory;
         }
     }
     catch (Exception)
     {
         fileSystemWebRoot = AppDomain.CurrentDomain.BaseDirectory;
     }
     return fileSystemWebRoot;
 }
コード例 #33
0
        /// <summary>
        /// returns a stack frame item from a stack frame. This 
        /// </summary>
        /// <param name="frame"></param>
        /// <returns></returns>
        public StackFrameItem(StackFrame frame)
        {
            // set default values
            m_lineNumber = NA;
            m_fileName = NA;
            m_method = new MethodItem();
            m_className = NA;

			try
			{
				// get frame values
				m_lineNumber = frame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
				m_fileName = frame.GetFileName();
				// get method values
				MethodBase method = frame.GetMethod();
				if (method != null)
				{
					if(method.DeclaringType != null)
						m_className = method.DeclaringType.FullName;
					m_method = new MethodItem(method);
				}
			}
			catch (Exception ex)
			{
				LogLog.Error(declaringType, "An exception ocurred while retreiving stack frame information.", ex);
			}

            // set full info
            m_fullInfo = m_className + '.' + m_method.Name + '(' + m_fileName + ':' + m_lineNumber + ')';
        }
コード例 #34
0
ファイル: Exceptions.cs プロジェクト: jwh5293/Composer
        public static void HandleException(Exception ex, string msg)
        {
            try
            {
                if (_exceptionUseReflection)
                {
                    var frame = new StackFrame(1);
                    frame.GetMethod();
                }
                if (ex.InnerException != null)
                {
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    msg = "**************" + msg + "**************" + Environment.NewLine;
                }
                else
                {
                    msg = Environment.NewLine;
                }
                var message = (_exceptionRecurseError) ? msg + RecurseErrorStack(ex) : msg;

                if (message.Length > 0)
                {
                    Ea.GetEvent<DisplayExceptionMessage>().Publish(message);
                    Ea.GetEvent<HideBusyIndicator>().Publish(string.Empty);
                }
            }
            catch (Exception iex)
            {
                throw (new Exception("Exception in HandleException(Exception ex, string msg): " + iex.Message));
            }
        }
コード例 #35
0
ファイル: MapleConsole.cs プロジェクト: BryceGough/MapleSharp
 public static void Write(LogType lt, string message)
 {
     StackFrame frame = new StackFrame(1);
     MethodBase method = frame.GetMethod();
     string loc = method.DeclaringType.Name;
     Write(lt, loc == "Main" ? "MapleSharp" : loc, message);
 }
コード例 #36
0
ファイル: StringUtil.cs プロジェクト: yabos/SaveTheQueen
    public static string StringFromStackTrace(System.DateTime dt, int frameDepth = 1)
    {
        System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(true);
        System.Diagnostics.StackFrame sf = st.GetFrame(frameDepth + 1);

        return(StringUtil.Format("time={0}, method={1}, file={2}, line={3}", dt.ToString(), sf.GetMethod().Name, System.IO.Path.GetFileName(sf.GetFileName()), sf.GetFileLineNumber()).ToString());
    }
コード例 #37
0
ファイル: JInvokeHelper.cs プロジェクト: javasuki/RJava
        /// <summary>
        /// 获取成员变量对应属性的缓存信息
        /// </summary>
        /// <param name="type">JObject继承类的类型</param>
        /// <param name="isSet">是否为设置值</param>
        /// <param name="fieldName">java成员变量名称</param>
        /// <returns>缓存信息对象实例</returns>
        public static JCacheInfo GetCacheFieldParam(Type type, bool isSet, string fieldName)
        {
            PropertyInfo pinfo = null;
            MethodBase dotnetMethod = null;
            int iNext = 2;
            do
            {
                StackFrame frame = new StackFrame(iNext++, true);
                dotnetMethod = frame.GetMethod();
                if (dotnetMethod == null) break;
                if (!dotnetMethod.IsSpecialName) continue;
                if (!dotnetMethod.DeclaringType.IsSubclassOf(typeof(JObject))) continue;

                BindingFlags bindingFlags = !dotnetMethod.IsStatic ? BindingFlags.IgnoreCase | BindingFlags.Public : BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public;
                type = dotnetMethod.DeclaringType;
                pinfo = type.GetProperty(fieldName);
                if (pinfo != null) break;
            }
            while (dotnetMethod != null);

            if (pinfo == null)
                throw new MethodAccessException("未找到调用链上的属性。");

            MethodInfo mi = (MethodInfo)dotnetMethod;
            bool isStatic = dotnetMethod.IsStatic;
            bool isVoid = mi.ReturnType == typeof(void);

            JCacheInfo jcacheInfo = new JCacheInfo { IsVoid = isVoid, IsStatic = isStatic, Name = fieldName };
            if (isSet)
                jcacheInfo.Params = mi.GetParameters().ToList();
            return jcacheInfo;
        }
コード例 #38
0
 public bool IsLoggingEnabled(LogLevel logLevel)
 {
     log4net.ILog logger;
     if (_loggerName != null && _loggerName.Trim() != string.Empty)
         logger = LogManager.GetLogger(_loggerName);
     else
     {
         Type type = new StackFrame(_frameToSkip, false).GetMethod().DeclaringType;
         logger = LogManager.GetLogger(type);
     }
     switch (logLevel)
     {
         case LogLevel.Debug:
             return logger.IsDebugEnabled;
         case LogLevel.Info:
             return logger.IsInfoEnabled;
         case LogLevel.Warn:
             return logger.IsWarnEnabled;
         case LogLevel.Error:
             return logger.IsErrorEnabled;
         case LogLevel.Fatal:
             return logger.IsFatalEnabled;
         case LogLevel.Off:
             return false;
         default:
             throw new Exception(string.Format("Unrecognized log level '{0}'.", logLevel.ToString()));
     }
 }
コード例 #39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionFrame"/> class.
        /// </summary>
        /// <param name="frame">The <see cref="StackFrame"/>.</param>
        public ExceptionFrame(StackFrame frame)
        {
            if (frame == null)
                return;

            int lineNo = frame.GetFileLineNumber();

            if (lineNo == 0)
            {
                //The pdb files aren't currently available
                lineNo = frame.GetILOffset();
            }

            var method = frame.GetMethod();
            if (method != null)
            {
                Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null;
                Function = method.Name;
                Source = method.ToString();
            }
            else
            {
                // on some platforms (e.g. on mono), StackFrame.GetMethod() may return null
                // e.g. for this stack frame:
                //   at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,object,object))

                Module = "(unknown)";
                Function = "(unknown)";
                Source = "(unknown)";
            }

            Filename = frame.GetFileName();
            LineNumber = lineNo;
            ColumnNumber = frame.GetFileColumnNumber();
        }
コード例 #40
0
        public void ShouldSetMemberfilterForMethodInfoOfTypeMethod()
        {
            StoryRunnerFilter filter = null;
            MemberInfo member = null;

            Given(
                () =>
                    {
                        var stack = new StackFrame(2); //
                        member = stack.GetMethod();
                    }
                );

            When(
                () => { filter = StoryRunnerFilter.GetFilter(member); }
                );

            Then(
                () =>
                    {
                        Assert.That(filter.MethodNameFiler.ToString(), Is.EqualTo("^ShouldSetMemberfilterForMethodInfoOfTypeMethod$"));
                        Assert.That(filter.ClassNameFilter.ToString(), Is.EqualTo("^" + typeof (StoryRunnerFilterSpecs).Name + "$"));
                        Assert.That(filter.NamespaceFilter.ToString(), Is.EqualTo("^" + typeof(StoryRunnerFilterSpecs).Namespace + "$"));
                    }
                );
        }
コード例 #41
0
        public OSAELog()
        {
            StackFrame frame = new StackFrame(1);
            MethodBase method = frame.GetMethod();
            Type type = method.DeclaringType;
            Log = LogManager.GetLogger(type);

            var root = ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root;
            var attachable = root as log4net.Core.IAppenderAttachable;

            if (attachable != null)
            {
                log4net.Repository.Hierarchy.Hierarchy hier = log4net.LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
                if (hier != null)
                {
                    var fileAppender =
                        (log4net.Appender.RollingFileAppender)hier.GetAppenders().Where(
                            appender => appender.Name.Equals("RollingLogFileAppender", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

                    var adoAppender =
                        (log4net.Appender.AdoNetAppender)hier.GetAppenders().Where(
                            appender => appender.Name.Equals("MySql_ADONetAppender", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

                    if (Common.TestConnection().Success)
                    {
                        if (adoAppender != null)
                        {
                            adoAppender.ConnectionString = Common.ConnectionString;
                            adoAppender.ActivateOptions();
                        }
                        root.RemoveAppender(fileAppender);
                    }
                }
            }
        }
コード例 #42
0
ファイル: MonitoringManager.cs プロジェクト: Mocahteam/FYFY
        /// <summary>
        ///     Trace game action.
        /// </summary>
        /// <param name="family">The monitored Family to use to build trace.</param>
        /// <param name="actionName">Action name you want to trace, this name has to match with a transition defined into associated Petri Net of the "family" parameter <see cref="ComponentMonitoring.PnmlFile"/>.</param>
        /// <param name="performedBy">Specify who perform this action, the player or the system. <see cref="MonitoringManager.Source"/></param>
        /// <param name="processLinks">Set to false if the logic expression associated to the action include "+" operators AND the action performed by the player is not allowed by the system. In this case fourth parameters will not be processed. True (default) means fourth parameter will be analysed.</param>
        /// <param name="linksConcerned">links label concerned by this action. You can leave empty if only "*" operators are used in logic expression. Must be defined if logic expression associated to the action include "+" operators. For instance, if logic expression is "(l0+l1)*l3" you have to indicate which links to use to build the trace: l0 and l3 OR l1 and l3 => <code>MonitoringManager.trace(..., "l0", "l3");</code> OR <code>MonitoringManager.trace(..., "l1", "l3");</code></param>
        /// <returns> labels found for this game action if in game analysis is enabled (see: MonitoringManager). return empty Array else </returns>
        public static string[] trace(Family family, string actionName, string performedBy, bool processLinks = true, params string[] linksConcerned)
        {
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true);                                                      // get caller stackFrame with informations
            string exceptionStackTrace = "(at " + stackFrame.GetFileName() + ":" + stackFrame.GetFileLineNumber().ToString() + ")";                     // to point where this function was called

            if (MonitoringManager.Instance == null)
            {
                throw new TraceAborted("No MonitoringManager found. You must add MonitoringManager component to one of your GameObject first (the Main_Loop for instance).", null);
            }

            FamilyMonitoring fm = MonitoringManager.Instance.getFamilyMonitoring(family);

            if (fm == null)
            {
                throw new TraceAborted("No monitor found for this family.", null);
            }

            string internalName = fm.getInternalName(actionName, exceptionStackTrace, processLinks, linksConcerned);

            if (fm.fullPnSelected >= MonitoringManager.Instance.PetriNetsName.Count)
            {
                fm.fullPnSelected = 1;
            }
            string pnName = MonitoringManager.Instance.PetriNetsName[fm.fullPnSelected];

            return(MonitoringManager.processTrace(pnName, internalName, performedBy));
        }
コード例 #43
0
        private void PrintException(Exception ex, List <GeneratedCode> generatedCodes)
        {
            var frames = new List <Interface.StackFrame>();

            var stackTrace = new StackTrace(ex, true);

            for (int i = 0; i < stackTrace.FrameCount; ++i)
            {
                System.Diagnostics.StackFrame diagnosticFrame = stackTrace.GetFrame(i);

                // Extract method name
                MethodBase method = diagnosticFrame.GetMethod();
                // Note(Maik): Skip internal render methods in case of a stack trace.
                if (Attribute.IsDefined(method, typeof(HideStackTraceAttribute)))
                {
                    continue;
                }
                Type declaringType = method.DeclaringType;
                var  methodSb      = new StringBuilder();
                if (declaringType != null)
                {
                    methodSb.Append(declaringType.FullName).Append(".");
                }
                methodSb.Append(method.Name);

                // Extract original filename, line and column
                int?line = null;
                if (diagnosticFrame.GetFileLineNumber() != 0)
                {
                    line = diagnosticFrame.GetFileLineNumber();
                }

                int?column = null;
                if (diagnosticFrame.GetFileColumnNumber() != 0)
                {
                    column = diagnosticFrame.GetFileColumnNumber();
                }

                string        filename      = diagnosticFrame.GetFileName();
                GeneratedCode generatedCode = generatedCodes.FirstOrDefault(gcode => string.Compare(gcode.TemplatePath, filename, StringComparison.OrdinalIgnoreCase) == 0);
                if ((generatedCode != null) && (line != null))
                {
                    var position = new TextPosition(line.Value, column ?? 1);
                    TextFilePosition original = generatedCode.SourceMap.FindSourceByGenerated(position);
                    if (original.IsValid)
                    {
                        filename = original.Name;
                        line     = original.Line;
                        column   = original.Column;
                    }
                }

                var msgFrame = new Interface.StackFrame(methodSb.ToString(), filename, line, column);
                frames.Add(msgFrame);
            } // for

            this.MessageHandler.Message(TraceLevel.Error, $"{ex.GetType().FullName}: {ex.Message}", string.Empty, new TextPosition());
            this.MessageHandler.StackTrace(frames);
        }
コード例 #44
0
    public void TrackSyncRequest(UnityEngine.Object spawned, string path)
    {
        var sf      = new System.Diagnostics.StackFrame(2, true);
        var request = NewRequest(path, sf);

        request.requestType = ResourceRequestType.Ordinary;
        TrackRequestWithObject(request, spawned);
    }
コード例 #45
0
ファイル: LogManager.cs プロジェクト: liuww111/HootEngine
        private void Log(string logtype, string msg, params object[] objs)
        {
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(2);
            System.Diagnostics.StackFrame sf = st.GetFrame(0);
            string meth = sf.GetMethod().Name;

            this.Log(logtype, typename, meth, msg, objs);
        }
コード例 #46
0
        /// <summary> 事件传送信息打印 </summary>
        public static void EventsMsg(object sender, object e, System.Diagnostics.StackFrame SourceFile)
        {
            string msg = string.Format("[FILE:{0} ],LINE:{1},{2}] sender:{3},e:{4}", SourceFile.GetFileName(), SourceFile.GetFileLineNumber(), SourceFile.GetMethod(), sender.GetType(), e.GetType());

            if (Logger != null)
            {
                Logger.Info(msg);
            }
        }
コード例 #47
0
ファイル: Trace.cs プロジェクト: wade1990/Elpis
        public static void Write(string format, params object[] args)
        {
#if TRACE
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(1);
            System.Reflection.MethodBase  methodBase = stackFrame.GetMethod();
            Console.WriteLine("[thread " + System.Threading.Thread.CurrentThread.ManagedThreadId + ", " + methodBase.DeclaringType.Name + "." + methodBase.Name + "] " + string.Format(format, args));
#endif
        }
コード例 #48
0
        public void Assert(bool condition, string message)
        {
            var callerMethodName = new Diag.StackFrame(2).GetMethod().Name;

            if (!condition)
            {
                throw new Exception("assert failed @ " + callerMethodName + " message:" + message);
            }
        }
コード例 #49
0
ファイル: Common.cs プロジェクト: rodibidably/git-tools
 public void ErrHandle(Exception ex, bool writeTrace = true)
 {
     if (writeTrace)
     {
         System.Diagnostics.StackFrame stackframe = new System.Diagnostics.StackFrame(1);
         string msg = stackframe.GetMethod().ReflectedType.FullName + "." + stackframe.GetMethod().Name + " - " + ex.Message;
         Trace(_Err + msg, false);
         /// ToDo: Do something else?
     }
 }
コード例 #50
0
ファイル: Contract.cs プロジェクト: LaichR/RuntimeCheck
 /// <summary>
 /// Used for function argument checking.
 /// Without specifying a exception type, the thrown exception will be of type ViolatedContractException
 /// </summary>
 /// <param name="condition">Condition that is checked for function arguments</param>
 /// <param name="message">The error message that is associated with the contract violation</param>
 /// <param name="args">Name of argment(s) that lead to the contract violation</param>
 public static void Requires(bool condition, string arg)
 {
     if (!condition)
     {
         var stackFrame = new System.Diagnostics.StackFrame(1, true);
         var method     = stackFrame.GetMethod();
         var methodName = string.Format("{0}.{1}(..)", method.DeclaringType.Name, method.Name);
         var message    = string.Format(ArgumentValidationFailedMsgTemplate, methodName);
         Requires <ViolatedContractException>(condition, message, arg);
     }
 }
コード例 #51
0
    public void TrackAsyncRequest(System.Object handle, string path)
    {
        var sf = new System.Diagnostics.StackFrame(2, true);

        if (sf.GetMethod().Name.Contains("SpawnAsyncOldVer"))
        {
            sf = new System.Diagnostics.StackFrame(3, true);
        }

        InProgressAsyncObjects[handle] = NewRequest(path, sf);
    }
コード例 #52
0
ファイル: DebugLog.cs プロジェクト: cosmiczilch/hungrynerds
        public static void PrintCodePosition(LogColor logColor)
        {
            StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true);
            string     message    = "-> { " + stackFrame.GetMethod().ToString() + " }";

            string[] filePath = stackFrame.GetFileName().Split('/');
            message += " in " + filePath[filePath.Length - 1]; // Append the file name
            message += "::" + stackFrame.GetFileLineNumber().ToString();
            DebugLog.LogColor(message, logColor);
            return;
        }
コード例 #53
0
ファイル: Tracing.cs プロジェクト: Plankankul/SpecSharp
 static void InternalTraceCall(int levels)
 {
     System.Diagnostics.StackFrame stack;
     stack = new System.Diagnostics.StackFrame(levels);
     System.Reflection.MethodBase method = stack.GetMethod();
     if (method != null)
     {
         string name = method.Name + " \tin class " + method.DeclaringType.Name;
         System.Diagnostics.Trace.WriteLine("Call Trace: \t" + name);
     }
 }
コード例 #54
0
        private static string FormatMessage(
            System.Diagnostics.StackTrace trace, string text, params object[] args)
        {
            System.Diagnostics.StackFrame frame = trace.GetFrame(1);
            string className  = frame.GetMethod().ReflectedType.FullName;
            string methodName = frame.GetMethod().Name;
            string message    = String.Format(
                "{0}/{1}: {2}", className, methodName, text);

            return(String.Format(message, args));
        }
コード例 #55
0
 static void InternalTraceCall(int levels)
 {
     System.Diagnostics.StackFrame stack;
     stack = new System.Diagnostics.StackFrame(levels);
     System.Reflection.MethodBase method = stack.GetMethod();
     if (method != null)
     {
         string name = method.Name + " \tin class " + method.DeclaringType.Name;
         XSharpProjectPackage.Instance.DisplayOutPutMessage("Call Trace: \t" + name);
     }
 }
コード例 #56
0
        /// <summary>
        /// Returns function name in call stack
        /// </summary>
        /// <returns></returns>
        private static string GetCallerName()
        {
            System.Diagnostics.StackTrace   st     = new System.Diagnostics.StackTrace(true); // true means get line numbers.
            System.Diagnostics.StackFrame[] frames = st.GetFrames();

            // [2] == <Caller>
            // [1] == TraceEnter()/TraceExit(),
            // [0] == GetCallerName(),
            System.Diagnostics.StackFrame f = frames[2];

            return(f.GetMethod().DeclaringType.Name + "." + f.GetMethod().Name);
        }
コード例 #57
0
    public void TrackResourcesDotLoad(UnityEngine.Object loaded, string path)
    {
        if (!_enableTracking)
        {
            return;
        }

        var sf      = new System.Diagnostics.StackFrame(1, true);
        var request = NewRequest(path, sf);

        request.requestType = ResourceRequestType.Ordinary;
        TrackRequestWithObject(request, loaded);
    }
コード例 #58
0
    /// <summary>
    /// Gets the callback info.
    /// </summary>
    /// <returns>The callback info.</returns>
    /// <param name="klass">only this.type </param>
    /// <param name="methodName"> only [ System.Reflection.MethodBase.GetCurrentMethod().Name) ] </param>
    public static CallbackInfo GetCallbackInfo(Type klass, string methodName)
    {
        int codeLine = new System.Diagnostics.StackFrame(0, true).GetFileLineNumber();

        var callbackInfo = new CallbackInfo()
        {
            className  = klass.FullName,
            methodName = methodName,
            line       = codeLine,
        };

        return(callbackInfo);
    }
コード例 #59
0
ファイル: UProcess.cs プロジェクト: rafeyhusain/InfinityChess
        public static string GetStackTrace()
        {
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(1);
            StringBuilder msg = new StringBuilder();

            for (int i = 0; i < st.FrameCount; i++)
            {
                System.Diagnostics.StackFrame sf = st.GetFrame(i);

                msg.AppendLine(sf.ToString());
            }

            return(msg.ToString());
        }
コード例 #60
0
ファイル: jDebug.cs プロジェクト: weimingtom/job_mobile
        private static string jFUNC(int iSkipFuncLevel = 1)
        {
            nSD.StackTrace st        = new nSD.StackTrace();
            nSD.StackFrame sf        = st.GetFrame(iSkipFuncLevel);
            nSD.StackFrame sf_prev   = st.GetFrame(iSkipFuncLevel + 1);
            string         prev_func = "";

            if (sf_prev != null)
            {
                prev_func = sf_prev.GetMethod().ToString();
            }

            return(prev_func + ">" + sf.GetMethod().ToString() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber());
        }