public void WriteFile( )
        {
            RecentComputerList computers = new RecentComputerList();
            computers.Add( new ComputerName( "1.1.1.1", "alias", true ) );
            computers.Add( new ComputerName( "work", null, false ) );

            StringWriter writer = new StringWriter();
            ComputerListFile serializer = new ComputerListFile();
            serializer.Write( writer, computers );

            Assert.AreEqual(
                "1.1.1.1\talias\tTrue\r\n" +
                "work\t\tFalse\r\n",
                writer.ToString() );
        }
        public void ReadFile( )
        {
            StringReader reader = new StringReader(
                "1.1.1.1\talias\tTrue\r\n" +
                "work\t\tFalse\r\n" +
                // The "classic" style, computer \t alias
                "2.2.2.2\tclassic\r\n" +
                "3.3.3.3\t\r\n" +
                "\r\n" +
                "4.4.4.4" );

            ComputerListFile serializer = new ComputerListFile();
            RecentComputerList computers = serializer.Read( reader );

            ComputerName[] cnames = new ComputerName[]
            {
                new ComputerName( "1.1.1.1", "alias", true ),
                new ComputerName( "work", null, false ),
                new ComputerName( "2.2.2.2", "classic", false ),
                new ComputerName( "3.3.3.3", null, false ),
                new ComputerName( "4.4.4.4", null, false )
            };
            Assert.AreEqual( cnames, computers.ToArray() );
        }
        public void MstscConnect( MstscSettings settings )
        {
            var mstscApp = new MstscApp();
            #if DEBUG
            mstscApp.TestMode = true;
            #endif
            try
            {
                mstscApp.Run( settings );
            }
            catch ( Exception ex )
            {
                Logger.LogException( ex );
            }

            OnMstscAppExited();

            // It is important to read before we write in case we have two instances of RemoteDesktopPlus open.
            // However RemoteDesktop doesn't have special logic for adding an IP address to the list like we
            // do so we need to do an integrate step.
            m_RecentComputerList = LoadRecentComputerList();

            // We use our own logic to determine what the recent computer list should be after a
            // connection was made.
            m_RecentComputerList.Push( settings.Computer );

            ComputerListFile serializer = new ComputerListFile();
            serializer.Write( m_RecentComputerList );

            OnComputerListUpdated();
        }
 private RecentComputerList LoadRecentComputerList( )
 {
     // Normally we read the computer list from our own setting file but on the first run
     // we will need import it from the registry.
     var listFile = new ComputerListFile();
     var computers = listFile.Read();
     if ( computers.Count == 0 )
     {
         Logger.LogString( "Computer list file not found.  Reading from registry." );
         computers = listFile.ReadFromRegistry();
     }
     return computers;
 }