/// <summary>
        /// Resolve Function name based on given AppDomain.
        /// </summary>
        /// <param name="functionName">The name of the function to resolve.</param>
        /// <param name="appDomain">The AppDomain to resolve in.</param>
        /// <returns></returns>
        public MDbgFunction ResolveFunctionNameFromScope(string functionName, CorAppDomain appDomain)
        {
            Debug.Assert(functionName != null &&
                         functionName.Length > 0);
            string moduleName = null;
            string className = null;
            string funcName = null;

            string tempParser = functionName;

            int bangIndex = tempParser.IndexOf("!");
            if (bangIndex != -1)
            {
                moduleName = tempParser.Substring(0, bangIndex);
                tempParser = tempParser.Substring(bangIndex + 1);
            }

            int periodIndex = tempParser.LastIndexOf(".");
            if (periodIndex == -1)
            {
                // only function is specified -- assuming current class
                className = Threads.Active.CurrentFrame.Function.MethodInfo.DeclaringType.Name;
                funcName = tempParser;
            }
            else
            {
                className = tempParser.Substring(0, periodIndex);
                funcName = tempParser.Substring(periodIndex + 1);
            }

            // The last argument to the ResolveFunctionName is appDomain we are refering to.
            // That will cause to resolution happen only on modules loaded into that appdomain.
            return ResolveFunctionName(moduleName, className, funcName, appDomain);
        }
        /// <summary>
        /// Resolves a Function from a Module, Class Name, Function Name, and AppDomain.
        /// </summary>
        /// <param name="moduleName">The Module name that has the Function.</param>
        /// <param name="className">The name of the Class that has the Function.</param>
        /// <param name="functionName">The name of the Function.</param>
        /// <param name="appDomain">The AppDomain to look in.</param>
        /// <returns>The MDbgFunction that matches the given parameters.</returns>
        public MDbgFunction ResolveFunctionName(string moduleName, string className, string functionName,
                                                CorAppDomain appDomain)
        {
            Debug.Assert(className != null);
            Debug.Assert(functionName != null);


            MDbgFunction func = null;

            if (moduleName != null)
            {
                MDbgModule module = Modules.Lookup(moduleName);
                if (module != null)
                {
                    CorAppDomain moduleAppDomain = module.CorModule.Assembly.AppDomain;
                    if (moduleAppDomain == null // not a shared assembly
                        || appDomain == null // we don't limit us to the certain appDomain
                        || appDomain == moduleAppDomain // the module is from correct domain
                        )
                    {
                        func = ResolveFunctionName(module, className, functionName);
                    }
                }
            }
            else
            {
                foreach (MDbgModule m in Modules)
                {
                    CorAppDomain moduleAppDomain = m.CorModule.Assembly.AppDomain;
                    if (moduleAppDomain == null // is a shared assembly
                        || appDomain == null // we don't limit us to the certain appDomain
                        || appDomain == moduleAppDomain // the module is from correct domain
                        )
                    {
                        func = ResolveFunctionName(m, className, functionName);
                        if (func != null)
                            break;
                    }
                }
            }

            return func;
        }