コード例 #1
0
ファイル: PB1Import.cs プロジェクト: aj9251/pandorasbox3
		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;
		}
コード例 #2
0
        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);
        }