Beispiel #1
0
        /// <summary>
        /// Вуаштуы
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="factory"></param>
        static void DefineOperation(string cmd, FtpMethodFactory factory)
        {
            // Define abstract ftp method
            // And add function to dictionary implements abstract ftp method
            // with concrete ftp method from methods factory
            AbstractFtpMethod method = factory.GetInstance(cmd);

            // if command already exists then throws exception
            if (commands.ContainsKey(cmd))
            {
                throw new ArgumentException(string.Format("Operation {0} already exists", cmd), "op");
            }
            commands.Add(cmd, method.SendRequest);
        }
Beispiel #2
0
        /// <summary>
        /// Welcome message. Also some params recieved from user to fill in AbstractFtpMethod class
        /// </summary>
        public static void WelcomeMessageAndInitParameters()
        {
            string uri, username, password;

            Console.Write("Welcome to console ftp client!\n\nEnter ftp server you want to use (without ftp://) (ftp.mozilla.org as default): ");
            uri = Console.ReadLine();
            Console.Write("Enter username: "******"Enter password: "******"")
            {
                AbstractFtpMethod.FtpUri = new Uri(uri, UriKind.RelativeOrAbsolute);
            }
            AbstractFtpMethod.Reloggin(username, password);
        }