public IHierarchicalEnumerable GetChildren()
        {
            HierarchicalCollection children = new HierarchicalCollection();

            foreach (Hierarchical Hierarchical in this.source)
            {
                if (Hierarchical.ParentID == this.Value)
                {
                    children.Add(Hierarchical);
                }
            }
            return(children);
        }
        public override IHierarchicalEnumerable Select()
        {
            HierarchicalCollection collection = new HierarchicalCollection();
            Int32 ParentId = (!String.IsNullOrEmpty(_viewPath)) ? Convert.ToInt32(_viewPath) : 0;

            foreach (Hierarchical Hierarchical in this._source)
            {
                if (Hierarchical.ParentID == ParentId)
                {
                    Hierarchical.source = _source;
                    collection.Add(Hierarchical);
                }
            }
            return(collection);
        }
        private void CreateCollection(HierarchicalObjectDataSource source)
        {
            IEnumerable data = source.Select();

            if (data != null)
            {
                foreach (Object dataItem in data)
                {
                    Int32  value    = Convert.ToInt32(DataBinder.GetPropertyValue(dataItem, source.DataValueField, null));
                    Int32  parentID = Convert.ToInt32(DataBinder.GetPropertyValue(dataItem, source.DataParentField, null));
                    String text     = DataBinder.GetPropertyValue(dataItem, source.DataTextField, null);
                    _source.Add(new Hierarchical(value, parentID, text));
                }
            }
        }
Example #4
0
        public static HierarchicalCollection GetData()
        {
            HierarchicalCollection collection = new HierarchicalCollection();

            collection.Add(new Hierarchical(1, 0, "Programming Languages"));
            collection.Add(new Hierarchical(2, 1, "Microsoft"));
            collection.Add(new Hierarchical(3, 2, "C#"));
            collection.Add(new Hierarchical(4, 2, "VB.net"));
            collection.Add(new Hierarchical(5, 1, "Open Source"));
            collection.Add(new Hierarchical(6, 5, "Python"));
            collection.Add(new Hierarchical(7, 5, "Ruby"));
            collection.Add(new Hierarchical(8, 5, "PHP"));
            collection.Add(new Hierarchical(9, 5, "Perl"));
            collection.Add(new Hierarchical(10, 5, "Java"));
            collection.Add(new Hierarchical(11, 3, "linQ"));
            collection.Add(new Hierarchical(12, 8, "5.2"));
            collection.Add(new Hierarchical(13, 8, "4.4"));
            return(collection);
        }