Exemple #1
0
        public void AddItem(string path, IComposite item)
        {
            IComposite composite = this;

            var names = path.Split('/');

            foreach (var name in names)
            {
                var child = composite.GetItem(name);

                if (child == null)
                {
                    var itemType = item.GetType();

                    child      = (IComposite)Activator.CreateInstance(itemType);
                    child.Name = name;

                    composite.AddItem(child);
                }

                composite = child;
            }

            composite.AddItem(item);
        }