Ejemplo n.º 1
0
		private void Trace(string message)
		{
			string method = null, type = null, parameters = null;
			for (var i = 2; i < 5; i++)
			{
				var cm = new StackFrame(i).GetMethod();
				if (cm.DeclaringType == typeof (CsDbDataSet) || cm.DeclaringType == typeof (CsDbTable<>))
					continue;

				type = cm.DeclaringType?.Name;
				method = cm.Name;
				parameters = cm.GetParameters().Select(x => x.Name).Join();
				break;
			}


			Debug.WriteLine($"DBTRACE @ {type}.{method}({parameters}) ".Expand(70) + $"!-> {message}");

		}
Ejemplo n.º 2
0
        internal static void GetMethodDetails(int frameToSkip, out string namespaceName, out string className, out string methodSignature)
        {
            StringBuilder output = new StringBuilder();
            MethodBase method = new StackFrame(frameToSkip, false).GetMethod();

            namespaceName = method.DeclaringType.Namespace;
            className = method.DeclaringType.Name;

            output.Append(method.Name);
            output.Append("(");

            ParameterInfo[] paramInfos = method.GetParameters();

            if (paramInfos.Length > 0)
            {
                output.Append("{0} {1}".FormatWith(paramInfos[0].ParameterType.Name, paramInfos[0].Name));

                if (paramInfos.Length > 1)
                {
                    for (int j = 1; j < paramInfos.Length; j++)
                    {
                        output.Append(", {0} {1}".FormatWith(paramInfos[j].ParameterType.Name, paramInfos[j].Name));
                    }
                }
            }

            output.Append(")");

            methodSignature = output.ToString();
        }