private static TheBox.Data.Facet Convert( LocationsList list ) { TheBox.Data.Facet f = new TheBox.Data.Facet(); StringCollection categories = new StringCollection(); foreach( Location loc in list.Places ) { if ( ! categories.Contains( loc.Category ) ) { categories.Add( loc.Category ); } } foreach( string cat in categories ) { TheBox.Common.GenericNode g = new TheBox.Common.GenericNode( cat ); f.Nodes.Add( g ); } foreach( TheBox.Common.GenericNode g in f.Nodes ) { StringCollection sub = new StringCollection(); foreach( Location loc in list.Places ) { if ( loc.Category == g.Name && ! sub.Contains( loc.Subsection ) ) { sub.Add( loc.Subsection ); } } foreach( string s in sub ) { TheBox.Common.GenericNode gSub = new TheBox.Common.GenericNode( s ); g.Elements.Add( gSub ); } } foreach( TheBox.Common.GenericNode gCat in f.Nodes ) { foreach( TheBox.Common.GenericNode gSub in gCat.Elements ) { foreach( Location loc in list.Places ) { if ( loc.Category == gCat.Name && loc.Subsection == gSub.Name ) { gSub.Elements.Add( Convert( loc ) ); } } } } return f; }
private static TheBox.Data.Facet Convert(LocationsList list) { TheBox.Data.Facet f = new TheBox.Data.Facet(); StringCollection categories = new StringCollection(); foreach (Location loc in list.Places) { if (!categories.Contains(loc.Category)) { categories.Add(loc.Category); } } foreach (string cat in categories) { TheBox.Common.GenericNode g = new TheBox.Common.GenericNode(cat); f.Nodes.Add(g); } foreach (TheBox.Common.GenericNode g in f.Nodes) { StringCollection sub = new StringCollection(); foreach (Location loc in list.Places) { if (loc.Category == g.Name && !sub.Contains(loc.Subsection)) { sub.Add(loc.Subsection); } } foreach (string s in sub) { TheBox.Common.GenericNode gSub = new TheBox.Common.GenericNode(s); g.Elements.Add(gSub); } } foreach (TheBox.Common.GenericNode gCat in f.Nodes) { foreach (TheBox.Common.GenericNode gSub in gCat.Elements) { foreach (Location loc in list.Places) { if (loc.Category == gCat.Name && loc.Subsection == gSub.Name) { gSub.Elements.Add(Convert(loc)); } } } } return(f); }