Beispiel #1
0
        /**
         * Call to Add Switches to the selection list view. Each item
         * in the list will hold an XPath representation of the Switch.
         */

        private void ProcessHardwareItemSwitching(Switching switching)
        {
            if (switching != null)
            {
                var g = new ListViewGroup("Switching", "Switching");
                lvNetworkPaths.Groups.Add(g);
                foreach (object item in switching.Items)
                {
                    if (item != null)
                    {
                        var idesc = item as Switch;
                        if (idesc != null)
                        {
                            Interface interfaces = idesc.Interface;
                            if (interfaces != null)
                            {
                                foreach (Port port in interfaces.Ports)
                                {
                                    if (port != null)
                                    {
                                        var xpath = new StringBuilder("//");
                                        xpath.Append(XPathManager.DeterminePathName(_hardwareItemDescription));
                                        xpath.Append("/").Append(XPathManager.DeterminePathName(switching));
                                        xpath.Append("/").Append(XPathManager.DeterminePathName(item));
                                        xpath.Append("[@name=\"")
                                        .Append(idesc.name)
                                        .Append("\"]");
                                        xpath.Append("/").Append(XPathManager.DeterminePathName(interfaces));
                                        xpath.Append("/").Append(XPathManager.DeterminePathName(interfaces.Ports));
                                        xpath.Append("/")
                                        .Append(XPathManager.DeterminePathName(port));
                                        xpath.Append("[@name=\"")
                                        .Append(port.name)
                                        .Append("\"]");

                                        string pathValues = NetworkNode.ExtractPathValues(xpath.ToString());
                                        var    lvi        = new ListViewItem(pathValues);
                                        lvi.Tag   = xpath.ToString();
                                        lvi.Group = g;
                                        lvNetworkPaths.Items.Add(lvi);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 private void ControlsToData()
 {
     if (lvList.Items.Count == 0)
     {
         _switching = null;
     }
     else
     {
         _switchItems.Clear();
         foreach (ListViewItem item in lvList.Items)
         {
             _switchItems.Add((Item)item.Tag);
         }
         if (_switching == null)
         {
             _switching = new Switching();
         }
         _switching.Items = _switchItems;
     }
 }