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;
     }
 }
 public static bool LoadFromFile(string fileName, out Switching obj)
 {
     Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an Switching object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Switching object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Switching obj, out Exception exception)
 {
     exception = null;
     obj = default(Switching);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string input, out Switching obj)
 {
     Exception exception;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an Switching object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output Switching object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out Switching obj, out Exception exception)
 {
     exception = null;
     obj = default(Switching);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
        /**
         * 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 );
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }