Exemplo n.º 1
0
    static void AddSpaceNameToTree(ToLuaTree <string> tree, ToLuaNode <string> root, string space)
    {
        if (space == null || space == string.Empty)
        {
            return;
        }

        string[]           ns     = space.Split(new char[] { '.' });
        ToLuaNode <string> parent = root;

        for (int j = 0; j < ns.Length; j++)
        {
            //pos变量
            ToLuaNode <string> node = tree.Find((_t) => { return(_t == ns[j]); }, j);

            if (node == null)
            {
                node       = new ToLuaNode <string>();
                node.value = ns[j];
                parent.childs.Add(node);
                node.parent = parent;
                //加入pos跟root里的pos比较,只有位置相同才是统一命名空间节点
                node.pos = j;
                parent   = node;
            }
            else
            {
                parent = node;
            }
        }
    }
Exemplo n.º 2
0
    static ToLuaTree <string> InitTree()
    {
        ToLuaTree <string> tree = new ToLuaTree <string>();
        ToLuaNode <string> root = tree.GetRoot();

        BindType[] list = GenBindTypes(CustomSettings.customTypeList);

        for (int i = 0; i < list.Length; i++)
        {
            string space = list[i].nameSpace;

            if (space == null || space == string.Empty)
            {
                continue;
            }

            string[]           ns     = space.Split(new char[] { '.' });
            ToLuaNode <string> parent = root;

            for (int j = 0; j < ns.Length; j++)
            {
                ToLuaNode <string> node = tree.Find((_t) => { return(_t == ns[j]); });

                if (node == null)
                {
                    node       = new ToLuaNode <string>();
                    node.value = ns[j];
                    parent.childs.Add(node);
                    node.parent = parent;
                    parent      = node;
                }
                else
                {
                    parent = node;
                }
            }
        }

        return(tree);
    }
Exemplo n.º 3
0
    static void AddSpaceNameToTree(ToLuaTree <string> tree, ToLuaNode <string> parent, string space)
    {
        if (space == null || space == string.Empty)
        {
            return;
        }

        string[] ns = space.Split(new char[] { '.' });

        for (int j = 0; j < ns.Length; j++)
        {
            List <ToLuaNode <string> > nodes = tree.Find((_t) => { return(_t == ns[j]); }, j);

            if (nodes.Count == 0)
            {
                ToLuaNode <string> node = new ToLuaNode <string>();
                node.value = ns[j];
                parent.childs.Add(node);
                node.parent = parent;
                node.layer  = j;
                parent      = node;
            }
            else
            {
                bool flag  = false;
                int  index = 0;

                for (int i = 0; i < nodes.Count; i++)
                {
                    int count = j;
                    int size  = j;
                    ToLuaNode <string> nodecopy = nodes[i];

                    while (nodecopy.parent != null)
                    {
                        nodecopy = nodecopy.parent;
                        if (nodecopy.value != null && nodecopy.value == ns[--count])
                        {
                            size--;
                        }
                    }

                    if (size == 0)
                    {
                        index = i;
                        flag  = true;
                        break;
                    }
                }

                if (!flag)
                {
                    ToLuaNode <string> nnode = new ToLuaNode <string>();
                    nnode.value  = ns[j];
                    nnode.layer  = j;
                    nnode.parent = parent;
                    parent.childs.Add(nnode);
                    parent = nnode;
                }
                else
                {
                    parent = nodes[index];
                }
            }
        }
    }
Exemplo n.º 4
0
    static ToLuaTree<string> InitTree()
    {                        
        ToLuaTree<string> tree = new ToLuaTree<string>();
        ToLuaNode<string> root = tree.GetRoot();        
        BindType[] list = GenBindTypes(CustomSettings.customTypeList);

        for (int i = 0; i < list.Length; i++)
        {
            string space = list[i].nameSpace;

            if (space == null || space == string.Empty)
            {
                continue;
            }

            string[] ns = space.Split(new char[] { '.' });
            ToLuaNode<string> parent = root;

            for (int j = 0; j < ns.Length; j++)
            {
                ToLuaNode<string> node = tree.Find((_t) => { return _t == ns[j];});

                if (node == null)
                {
                    node = new ToLuaNode<string>();
                    node.value = ns[j];
                    parent.childs.Add(node);
                    node.parent = parent;
                    parent = node;
                }
                else
                {
                    parent = node;
                }
            }
        }

        return tree;
    }
Exemplo n.º 5
0
    static void AddSpaceNameToTree(ToLuaTree<string> tree, ToLuaNode<string> parent, string space)
    {
        if (space == null || space == string.Empty)
        {
            return;
        }

        string[] ns = space.Split(new char[] { '.' });

        for (int j = 0; j < ns.Length; j++)
        {
            List<ToLuaNode<string>> nodes = tree.Find((_t) => { return _t == ns[j]; }, j);

            if (nodes.Count == 0)
            {
                ToLuaNode<string> node = new ToLuaNode<string>();
                node.value = ns[j];
                parent.childs.Add(node);
                node.parent = parent;
                node.layer = j;
                parent = node;
            }
            else
            {
                bool flag = false;
                int index = 0;

                for (int i = 0; i < nodes.Count; i++)
                {
                    int count = j;
                    int size = j;
                    ToLuaNode<string> nodecopy = nodes[i];

                    while (nodecopy.parent != null)
                    {
                        nodecopy = nodecopy.parent;
                        if (nodecopy.value != null && nodecopy.value == ns[--count])
                        {
                            size--;
                        }
                    }

                    if (size == 0)
                    {
                        index = i;
                        flag = true;
                        break;
                    }
                }

                if (!flag)
                {
                    ToLuaNode<string> nnode = new ToLuaNode<string>();
                    nnode.value = ns[j];
                    nnode.layer = j;
                    nnode.parent = parent;
                    parent.childs.Add(nnode);
                    parent = nnode;
                }
                else
                {
                    parent = nodes[index];
                }
            }
        }
    }
Exemplo n.º 6
0
    static void AddSpaceNameToTree(ToLuaTree<string> tree, ToLuaNode<string> root, string space)
    {
        if (space == null || space == string.Empty)
        {
            return;
        }

        string[] ns = space.Split(new char[] { '.' });
        ToLuaNode<string> parent = root;

        for (int j = 0; j < ns.Length; j++)
        {
            //pos变量
            ToLuaNode<string> node = tree.Find((_t) => { return _t == ns[j]; }, j);

            if (node == null)
            {
                node = new ToLuaNode<string>();
                node.value = ns[j];
                parent.childs.Add(node);
                node.parent = parent;
                //加入pos跟root里的pos比较,只有位置相同才是统一命名空间节点
                node.pos = j;
                parent = node;
            }
            else
            {
                parent = node;
            }
        }
    }