/// <summary> /// Removes a location from the list /// </summary> /// <param name="loc">The location object that should be deleted</param> /// <param name="category">The category it belongs to</param> /// <param name="subsection">The subsection parent of the location</param> public void DeleteLocation( Location loc, string category, string subsection ) { foreach ( GenericNode cat in m_Nodes ) { if ( cat.Name.ToLower() == category.ToLower() ) { foreach ( GenericNode sub in ( cat.Elements ) ) { if ( sub.Name.ToLower() == subsection.ToLower() ) { foreach ( Location l in sub.Elements ) { if ( l == loc ) { sub.Elements.Remove( loc ); return; } } } } } } }
/// <summary> /// Adds a new location to this facet /// </summary> /// <param name="loc">The location that should be added</param> /// <param name="category">The category name for the new location</param> /// <param name="subsection">The subsection name for the new location</param> public void AddLocation( Location loc, string category, string subsection ) { GenericNode catNode = null; foreach ( GenericNode cat in m_Nodes ) { if ( cat.Name.ToLower() == category.ToLower() ) { catNode = cat; break; } } if ( catNode == null ) { catNode = new GenericNode( category ); m_Nodes.Add( catNode ); } GenericNode subNode = null; foreach( GenericNode sub in catNode.Elements ) { if ( sub.Name.ToLower() == subsection.ToLower() ) { subNode = sub; break; } } if ( subNode == null ) { subNode = new GenericNode( subsection ); catNode.Elements.Add( subNode ); } subNode.Elements.Add( loc ); }