Esempio n. 1
0
        /// <summary>
        /// Resolves a function instance via the .NET stack.
        /// </summary>
        private static UserDefinedFunction ResolveFunctionInstance(int count)
        {
            // First, get the stack:
            System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(5 + count, true);

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

                UserDefinedFunction func = MethodLookup.Search(frame.GetMethod() as MethodInfo);

                if (func != null)
                {
                    return(func);
                }
            }

            return(null);
        }