VSNDK.DebugEngine.VariableInfo.listChildren C# (CSharp) Method

listChildren() public method

Gets the list of children for a given variable.
public listChildren ( EventDispatcher dispatcher, string parentType, ArrayList GDBNames, ArrayList VSNames, bool hasVsNdK_, string GDBName ) : void
dispatcher EventDispatcher The event dispatcher.
parentType string The variable's parent data type. "*" means it is a pointer; "struct[]" means it is an array of /// structures; "struct" means it is a structure; and "[]" means it is an array.
GDBNames System.Collections.ArrayList The names of the variables used by GDB.
VSNames System.Collections.ArrayList The Names of the variables used by VS.
hasVsNdK_ bool Indicate if the variable name uses or not the prefix "VsNdK_".
GDBName string The GDB Name of the variable.
return void
        public void listChildren(EventDispatcher dispatcher, string parentType, ArrayList GDBNames, ArrayList VSNames, bool hasVsNdK_, string GDBName)
        {
            string childListResponse;
            if (GDBName == null)
            {
                if (hasVsNdK_)
                {
                    childListResponse = dispatcher.listChildren(_GDBName);
                }
                else
                {
                    childListResponse = dispatcher.listChildren(_name);
                    if ((childListResponse == "ERROR") && (_GDBName != null))
                    {
                        childListResponse = dispatcher.listChildren(_GDBName);
                    }
                }
            }
            else
                childListResponse = dispatcher.listChildren(GDBName);

            if (childListResponse != "ERROR")
            {
                childListResponse = (childListResponse.Substring(3)).Replace("#;;;", "");

                string[] childList = childListResponse.Split('#');
                foreach (string childString in childList)
                {
                    string name = null;
                    string type = null;
                    string value = null;
                    int numChildren = 0;
                    bool valid = true;

                    string[] childProperties = childString.Split(';');

                    if (childProperties[0] == "")
                        continue;

                    name = childProperties[0];

                    if (name.Contains("::")) // discard this GDB expression.
                    {
                        continue;
                    }

                    GDBName = name;

                    int end = name.Length;
                    if (name[end - 1] == '"')
                        end--;
                    if (((name.Length > 8) && (name.Substring(end - 8, 8) == ".private")) ||
                        ((name.Length > 7) && (name.Substring(end - 7, 7) == ".public")) ||
                        ((name.Length > 10) && (name.Substring(end - 10, 10) == ".protected")) ||
                        ((name.Length > 9) && (name.Substring(end - 9, 9) == ".private.")) ||
                        ((name.Length > 8) && (name.Substring(end - 8, 8) == ".public.")) ||
                        ((name.Length > 11) && (name.Substring(end - 11, 11) == ".protected.")))
                    {
                        // GDB is using an intermediate representation for the variable. Inquire GDB again using this intermediate name.
                        int index = VSNames.IndexOf(_name);
                        if (index != -1)
                            GDBNames[index] = GDBName;
                        else
                        {
                            GDBNames.Add(GDBName);
                            VSNames.Add(_name);
                        }
                        this.listChildren(dispatcher, parentType, GDBNames, VSNames, hasVsNdK_, GDBName);
                        continue;
                    }
                    else
                    {
                        int dot = name.LastIndexOf(".");
                        if (dot != -1)
                        {
                            int index = GDBNames.IndexOf(name.Substring(0, dot));
                            if (index != -1)
                            {
                                name = VSNames[index].ToString() + name.Substring(dot);
                            }
                        }

                        name = name.Replace(".private", "");
                        name = name.Replace(".public", "");
                        name = name.Replace(".protected", "");
                        name = name.Replace("..", ".");

                        dot = name.LastIndexOf(".*");
                        if (dot != -1)
                        {
                            name = "*(" + name.Remove(dot) + ")";
                        }

                        if (parentType == "*")
                        {
                            dot = name.LastIndexOf('.');
                            if (dot != -1)
                            {
                                name = name.Substring(0, dot) + "->" + name.Substring(dot + 1, name.Length - (dot + 1));
                            }
                        }
                        else if (parentType == "[]")
                        {
                            dot = name.LastIndexOf('.');
                            name = name.Substring(0, dot) + "[" + name.Substring(dot + 1, name.Length - (dot + 1));
                            name = name + "]";
                        }
                        GDBNames.Add(GDBName);
                        VSNames.Add(name);
                    }

                    if (childProperties[1] != "")
                        numChildren = Convert.ToInt32(childProperties[1]);

                    value = childProperties[2];
                    if ((value == "") || (value.Contains("{...}")) ||
                        ((value.Length >= 2) && (value[0] == '[') && (value[value.Length - 1] == ']')))
                        valid = evaluateExpression(name, ref value, GDBName);

                    type = childProperties[3];

                    VariableInfo child = new VariableInfo(name, type, value, GDBName);

                    if ((valid) && (numChildren > 0 && value != "0x0"))
                    {
                        child._children = new ArrayList();
                    }
                    if (VSNames.Contains(name))
                    {
                        int index = VSNames.IndexOf(name);
                        VSNames.RemoveAt(index);
                        GDBNames.RemoveAt(index);
                    }
                    _children.Add(child); // If VS knows that there are children, it will inquiries again if those children data
                                          // were not filled.
                }
            }
        }