Example #1
0
        public object Clone()
        {
            ArrayNode clone = new ArrayNode(Name);

            // only clone structure
            clone.mDefaultPath = mDefaultPath.Clone() as IDataNode;

            return(clone);
        }
Example #2
0
        public T Register <T>(string path) where T : INodeData, new()
        {
            path += '.';

            string    name = string.Empty;
            IPathNode last = mRoot;

            for (int i = 0; i < path.Length; ++i)
            {
                char c = path[i];

                if (c == '.')
                {
                    if (!string.IsNullOrEmpty(name) || last is ArrayNode)
                    {
                        MapNode node = new MapNode(name);
                        last = last.AddChild(node);
                        name = string.Empty;
                    }
                }
                else if (c == '[')
                {
                    ArrayNode node = new ArrayNode(name);
                    last = last.AddChild(node);
                    name = string.Empty;
                }
                else if (c == ']')
                {
                    name = string.Empty;
                }
                else
                {
                    name += c;
                }
            }

            IDataNode dataNode = last as IDataNode;

            if (dataNode.Value != null)
            {
                EB.Debug.LogWarning("Register: already registered {0}", path);
            }
            T value = new T();

            dataNode.Value = value;

            return(value);
        }