Esempio n. 1
0
 public static void Main(string[] argv)
 {
     //check to see if the client has entered his name
     //if not ask him if he wants to enter his name.
     if (argv.Length <= 0)
     {
         Console.WriteLine("Usage: DataClient <yourname>");
         Console.Write("Would You like to enter your name now [y/n] ?");
         char check = Console.ReadLine().ToCharArray()[0];
         if (check == 'y' || check == 'Y')
         {
             Console.Write("Please enter you name :");
             string     newname = Console.ReadLine();
             DateClient dc      = new DateClient(newname);
             Console.WriteLine("Disconnected!!");
             Console.ReadLine();
         }
     }
     else
     {
         DateClient dc = new DateClient(argv[0]);
         Console.WriteLine("Disconnected!!");
         Console.ReadLine();
     }
 }
 public static void Main(String[] args)
 {
     if (args.Length != 2)
     {
         PrintUsage();
         return;
     }
     try {
         DateClient myDateClient = new DateClient(IPAddress.Parse(args[0]), Int32.Parse(args[1]));
         String     currentDate  = myDateClient.GetDate();
         Console.WriteLine("The current date and time is : ");
         Console.WriteLine("{0}", currentDate);
     }
     // This exception is thrown by the called method in the context of improper permissions.
     catch (SecurityException e) {
         Console.WriteLine("\nSecurityException raised : {0}", e.Message);
     }
     catch (Exception e) {
         Console.WriteLine("\nException raised : {0}", e.Message);
     }
 }
Esempio n. 3
0
 public DateController(DateClient dateClient)
 {
     _dateClient = dateClient;
 }
Esempio n. 4
0
    public static void Main(string[] argv)
    {
        //check to see if the client has entered his name
        //if not ask him if he wants to enter his name.
        if(argv.Length<=0)
        {
            Console.WriteLine("Usage: DataClient <yourname>") ;
            Console.Write("Would You like to enter your name now [y/n] ?") ;
            char check = Console.ReadLine().ToCharArray()[0];
            if(check=='y'|| check=='Y')
            {
                Console.Write("Please enter you name :") ;
                string newname=Console.ReadLine();
                DateClient dc = new DateClient(newname) ;
                Console.WriteLine("Disconnected!!") ;
                Console.ReadLine() ;

            }

        }
        else
        {
            DateClient dc = new DateClient(argv[0]) ;
            Console.WriteLine("Disconnected!!") ;
            Console.ReadLine() ;
        }
    }