Mono.Debugger.Frontend.ScriptingContext.GetNamespaces C# (CSharp) Method

GetNamespaces() public method

public GetNamespaces ( ) : string[]
return string[]
        public string[] GetNamespaces()
        {
            if (HasFrame) {
                Method method = CurrentFrame.Method;
                if ((method == null) || !method.HasLineNumbers)
                    return null;

                return method.GetNamespaces ();
            }

            if (ImplicitInstance != null) {
                string full_name = ImplicitInstance.Type.Name;

                List<string> list = new List<string> ();

                int pos;
                int start = full_name.Length - 1;
                while ((pos = full_name.LastIndexOf ('.', start)) > 0) {
                    list.Add (full_name.Substring (0, pos));
                    start = pos - 1;
                }

                return list.ToArray ();
            }

            return null;
        }

Usage Example

Ejemplo n.º 1
0
        public string[] SymbolCompleter(ScriptingContext context, string text)
        {
            try {
                var      method_list = new List <string> ();
                string[] namespaces  = context.GetNamespaces();
                Module[] modules     = context.CurrentProcess.Modules;

                foreach (Module module in modules)
                {
                    if (!module.SymbolsLoaded || !module.SymbolTable.HasMethods)
                    {
                        continue;
                    }

                    SourceFile[] sources = module.Sources;
                    if (sources == null)
                    {
                        continue;
                    }

                    foreach (SourceFile sf in sources)
                    {
                        foreach (MethodSource method in sf.Methods)
                        {
                            if (method.Name.StartsWith(text))
                            {
                                int parameter_start = method.Name.IndexOf('(');
                                if (parameter_start != -1)
                                {
                                    method_list.Add(method.Name.Substring(0, parameter_start));
                                }
                                else
                                {
                                    method_list.Add(method.Name);
                                }
                            }
                            if (namespaces != null)
                            {
                                foreach (string n in namespaces)
                                {
                                    if (n != "" && method.Name.StartsWith(String.Concat(n, ".", text)))
                                    {
                                        int parameter_start = method.Name.IndexOf('(');
                                        if (parameter_start != -1)
                                        {
                                            method_list.Add(method.Name.Substring(n.Length + 1,
                                                                                  parameter_start - n.Length - 1));
                                        }
                                        else
                                        {
                                            method_list.Add(method.Name.Substring(n.Length + 1));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(method_list.ToArray());
            } catch {
                return(null);
            }
        }
All Usage Examples Of Mono.Debugger.Frontend.ScriptingContext::GetNamespaces