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


C# StackFrame.GetMethod方法代码示例

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


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

示例1: WhoAmI

    public void WhoAmI(string arg1)
    {
        Assembly assembly = Assembly.GetExecutingAssembly();
        System.Type t = assembly.GetType(this.ToString());	// Get only this class
        Console.WriteLine("This class name is: {0}", t.ToString());
        MethodInfo[] mInfo = t.GetMethods();
        MemberInfo[] bInfo = t.GetMembers();
        FieldInfo[]  fInfo = t.GetFields();
        foreach (MethodInfo m in mInfo)
                Console.WriteLine("Method:  {0}", m.Name);
        foreach (MemberInfo b in bInfo)
                Console.WriteLine("Member:  {0}", b.Name);
        foreach (FieldInfo f in fInfo)
                Console.WriteLine("Field:  {0}", f.Name);

        StackFrame stackFrame = new StackFrame();
        MethodBase methodBase = stackFrame.GetMethod();
        Console.WriteLine("This method name is : {0}", methodBase.Name );

        /*System.Type[] types = assembly.GetTypes();
        foreach (System.Type t in types)
        {
            Console.WriteLine("Tipo: {0}", t.ToString());
            MethodInfo[] mInfo = t.GetMethods();
            MemberInfo[] bInfo = t.GetMembers();
            foreach (MethodInfo m in mInfo)
                    Console.WriteLine("Modulo:  {0}", m.Name);
            foreach (MemberInfo b in bInfo)
                    Console.WriteLine("Miembro:  {0}", b.Name);
        }*/
    }
开发者ID:BackupTheBerlios,项目名称:boxerp-svn,代码行数:31,代码来源:Info.cs

示例2: ToLogString

    public static string ToLogString(this Exception excep, StackFrame stackFrame, object AdditionalInfo)
    {
        StringBuilder sb = new StringBuilder();

        #if (! UNITY_IPHONE)
        // stack frame info
        MethodBase methodBase = stackFrame.GetMethod();

        sb.AppendFormat("Exception Location:{0}", nl);
        sb.AppendFormat("{0}Namespace: {1}{2}", tab, methodBase.ReflectedType.Namespace, nl);
        sb.AppendFormat("{0}Class Name: {1}{2}", tab, methodBase.ReflectedType.Name, nl);
        sb.AppendFormat("{0}Method Name: {1}{2}", tab, methodBase.Name, nl);
        #endif

        // build the exception info string
        sb.AppendFormat("Exception Information:{0}", nl);
        sb.AppendFormat("{2}Message: {0}{1}", excep.Message, nl, tab);
        sb.AppendFormat("{2}Source: {0}{1}{1}", excep.Source, nl, tab);
        sb.AppendFormat("Stack Trace: {1} {0}{1}{1}", excep.StackTrace, nl);

        // inner exception
        if (excep.InnerException != null)
        {
            sb.AppendFormat("{1}{0}Inner Exception Info:{0}", nl, tab);
            sb.AppendFormat("{2}{2}Message: {0}{1}", excep.InnerException.Message, nl, tab);
            sb.AppendFormat("{2}{2}Source: {0}{1}", excep.InnerException.Source, nl, tab);
            sb.AppendFormat("{2}{2}Stack Trace: {0}{1}", excep.InnerException.StackTrace, nl, tab);
        }

        // additional info
        if (AdditionalInfo != null)
        {
            sb.AppendFormat("Additional Object Info{0}", nl);
        #if (! UNITY_IPHONE)
            sb.AppendFormat("{0}{1}{2}", tab, ObjectDumper.GetObjectValue(AdditionalInfo), nl);
        #else
            sb.AppendFormat("{0}{1}{2}", tab, AdditionalInfo.ToString(), nl);
        #endif
        }

        // device info
        sb.AppendFormat("Device Info:{0}", nl);
        sb.AppendFormat("{2}Device OS: {0} {1}", SystemInfo.operatingSystem, nl, tab);
        sb.AppendFormat("{2}Device Model: {0} {1}", SystemInfo.deviceModel, nl, tab);
        sb.AppendFormat("{2}Device Type: {0} {1}", SystemInfo.deviceType, nl, tab);
        sb.AppendFormat("{2}Device Name: {0} {1}", SystemInfo.deviceName, nl, tab);
        sb.AppendFormat("{2}Device ID: {0} {1}", SystemInfo.deviceUniqueIdentifier, nl, tab);
        sb.AppendFormat("{2}Device Memory: {0} {1}", SystemInfo.systemMemorySize, nl, tab);

        return sb.ToString();
    }
开发者ID:rocketgames,项目名称:Extension-Methods-for-Unity,代码行数:51,代码来源:ExceptionExtensions.cs

示例3: InternalWrite

    private static void InternalWrite(TraceLevel level, string format, params object[] args)
    {
        try
        {
            if (_init == 0)
            {
                if (0 == System.Threading.Interlocked.Exchange(ref _init, 1))
                { Open(); }
            }

            int depth = 2;
            if (args.Length > 0)
                format = String.Format(format, args);

            if (level <= _consoleLogLevel)
                Console_LogWrite(level, format);

            StackFrame frame;
            System.Reflection.MethodBase method;

            do
            {
                frame = new StackFrame(depth++);
                method = frame.GetMethod();
            }
            while (method.ReflectedType.FullName.StartsWith("System.", StringComparison.OrdinalIgnoreCase) ||
                method.ReflectedType.GetCustomAttributes(typeof(System.Diagnostics.DebuggerNonUserCodeAttribute), true).Length > 0);

            string methodName, callingType;
            methodName = String.Format("{0}", method);
            callingType = String.Format("{0}", method.ReflectedType);

            string full = String.Format("{0:D2}{1,8} - {2}   at {3}",
                System.Threading.Thread.CurrentThread.ManagedThreadId,
                level == TraceLevel.Off ? "None" : level.ToString(),
                format, methodName);

            Trace.WriteLine(full, callingType);

            if (LogWrite != null)
                LogWrite(method, level, format);
        }
        catch (Exception e)
        { Trace.WriteLine(e.ToString(), "CSharpTest.Net.QuickLog.Write()"); }
    }
开发者ID:modulexcite,项目名称:CSharpTest.Net.Tools,代码行数:45,代码来源:QuickLog.cs

示例4: GetCurrentClassLogger

        public Logger GetCurrentClassLogger(Type loggerType)
        {
#if !SILVERLIGHT
            var frame = new StackFrame(1, false);
#else
            var frame = new StackFrame(1);
#endif

            return this.GetLogger(frame.GetMethod().DeclaringType.FullName, loggerType);
        }
开发者ID:shiftkey,项目名称:winrt-backport-hilarity,代码行数:10,代码来源:LogFactory.cs

示例5: Leave

 public static void Leave()
 {
     StackFrame stack = new StackFrame(1, true);
     Logger.AddMsg(String.Format("Leave {0}, {1}:{2}"
         , stack.GetMethod().Name
         , stack.GetFileName()
         , stack.GetFileLineNumber())
     , LogLevel.Debug);
 }
开发者ID:AndrianDTR,项目名称:Atlantic,代码行数:9,代码来源:Logger.cs

示例6: FormatStackFrame

        private static string FormatStackFrame(StackFrame f) {
            System.Reflection.MethodBase mb = f.GetMethod();
            if(mb == null) return "<unknown>";
            string method = string.Format("{0}.{1}", mb.DeclaringType.Name, mb.Name);

            string file = f.GetFileName();
            if(file == null) return method;
            else return string.Format("{0} in \"{1}\":{2}:{3}", method, file, f.GetFileLineNumber(), f.GetFileColumnNumber());
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:9,代码来源:Synchronizer.cs

示例7: smethod_4


//.........这里部分代码省略.........
			IntPtr zero = IntPtr.Zero;
			int num = binaryReader.ReadInt32();
			binaryReader.ReadInt32();
			for (int i = 0; i < num; i++)
			{
				if (IntPtr.Size == 4)
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.int_2 + binaryReader.ReadInt32()), BitConverter.GetBytes(binaryReader.ReadInt32()), 4u, out zero);
				}
				else
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.long_0 + (long)binaryReader.ReadInt32()), BitConverter.GetBytes(binaryReader.ReadInt32()), 4u, out zero);
				}
			}
			while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length - 1L)
			{
				int num2 = binaryReader.ReadInt32();
				int num3 = binaryReader.ReadInt32();
				int num4 = binaryReader.ReadInt32();
				byte[] byte_ = binaryReader.ReadBytes(num4);
				if (num3 > 0)
				{
					Class0.sortedList_0[num3] = num2;
				}
				if (IntPtr.Size == 4)
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.int_2 + num2), byte_, Convert.ToUInt32(num4), out zero);
				}
				else
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.long_0 + (long)num2), byte_, Convert.ToUInt32(num4), out zero);
				}
			}
			int metadataToken = new StackFrame(1).GetMethod().MetadataToken;
			object obj = Class0.sortedList_0[metadataToken];
			if (obj != null)
			{
				if (IntPtr.Size == 4)
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.int_2 + (int)obj), new byte[]
					{
						255,
						255,
						255,
						255
					}, 4u, out zero);
				}
				else
				{
					Class0.WriteProcessMemory(intptr_, new IntPtr(Class0.long_0 + (long)((int)obj)), new byte[]
					{
						255,
						255,
						255,
						255
					}, 4u, out zero);
				}
				Class0.sortedList_0.Remove(metadataToken);
			}
			StackFrame stackFrame = new StackFrame(2);
			if (stackFrame.GetMethod() != null)
			{
				int metadataToken2 = stackFrame.GetMethod().MetadataToken;
				object obj2 = Class0.sortedList_0[metadataToken2];
				if (obj2 != null)
				{
开发者ID:akordowski,项目名称:Source-Code-Nitriq,代码行数:67,代码来源:Class0.cs

示例8: StackFrameToString

        //--
        //-- turns a single stack frame object into an informative string
        //--
        private static string StackFrameToString(StackFrame sf)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            int intParam = 0;
            MemberInfo mi = sf.GetMethod();

            var _with1 = sb;
            //-- build method name
            _with1.Append("   ");
            _with1.Append(mi.DeclaringType.Namespace);
            _with1.Append(".");
            _with1.Append(mi.DeclaringType.Name);
            _with1.Append(".");
            _with1.Append(mi.Name);

            //-- build method params
            ParameterInfo[] objParameters = sf.GetMethod().GetParameters();
            ParameterInfo objParameter = null;
            _with1.Append("(");
            intParam = 0;
            foreach (ParameterInfo objParameter_loopVariable in objParameters)
            {
                objParameter = objParameter_loopVariable;
                intParam += 1;
                if (intParam > 1)
                    _with1.Append(", ");
                _with1.Append(objParameter.Name);
                _with1.Append(" As ");
                _with1.Append(objParameter.ParameterType.Name);
            }
            _with1.Append(")");
            _with1.Append(Environment.NewLine);

            //-- if source code is available, append location info
            _with1.Append("       ");
            if (sf.GetFileName() == null || sf.GetFileName().Length == 0)
            {
                _with1.Append(System.IO.Path.GetFileName(ParentAssembly().CodeBase));
                //-- native code offset is always available
                _with1.Append(": N ");
                _with1.Append(string.Format("{0:#00000}", sf.GetNativeOffset()));
            }
            else
            {
                _with1.Append(System.IO.Path.GetFileName(sf.GetFileName()));
                _with1.Append(": line ");
                _with1.Append(string.Format("{0:#0000}", sf.GetFileLineNumber()));
                _with1.Append(", col ");
                _with1.Append(string.Format("{0:#00}", sf.GetFileColumnNumber()));
                //-- if IL is available, append IL location info
                if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
                {
                    _with1.Append(", IL ");
                    _with1.Append(string.Format("{0:#0000}", sf.GetILOffset()));
                }
            }
            _with1.Append(Environment.NewLine);
            return sb.ToString();
        }
开发者ID:nerndt,项目名称:iRobotKinect,代码行数:62,代码来源:ExceptionHandling.cs

示例9: Assert

    public static void Assert(bool assertVal, string message)
    {
        if( assertVal != true )
        {
            StackFrame sf = new StackFrame(1);
            MethodBase mb = sf.GetMethod();
            System.Type t = mb.DeclaringType;

            string s = message + System.String.Format("\nMETHODCALL {0}::{1}\n", t.Name, mb.Name);

            UnityEngine.Debug.Log(s);

            if( OnAssert != null ) {
                OnAssert(null, new DbgEventArgs(s));
            }

            // then pause the editor
            UnityEngine.Debug.Break();
        }
    }
开发者ID:JosephLaurino,项目名称:Dbg,代码行数:20,代码来源:Dbg.cs

示例10: LogMethodCall

    public static void LogMethodCall(eChannelType channel)
    {
        if( DEBUG_CHANNELS[(int)channel] == true )
        {
            StackFrame sf = new StackFrame(1);
            MethodBase mb = sf.GetMethod();
            System.Type t = mb.DeclaringType;

            string s = System.String.Format(channel.ToString() + ": " + "METHODCALL {0}::{1} \n", t.Name, mb.Name);
            UnityEngine.Debug.Log(s);

            if( OnLogMethodCall != null ) {
                OnLogMethodCall(null, new DbgEventArgs(s));
            }
        }
    }
开发者ID:JosephLaurino,项目名称:Dbg,代码行数:16,代码来源:Dbg.cs

示例11: GetCurrentClassLogger

        public static Logger GetCurrentClassLogger(Type loggerType)
        {
#if SILVERLIGHT
            StackFrame frame = new StackTrace().GetFrame(1);
#else
            StackFrame frame = new StackFrame(1, false);
#endif
            return globalFactory.GetLogger(frame.GetMethod().DeclaringType.FullName, loggerType);
        }
开发者ID:shiftkey,项目名称:winrt-backport-hilarity,代码行数:9,代码来源:LogManager.cs


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