Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var directory = new FileDirectory(Path.Combine(Directory.GetCurrentDirectory(), "Documents"));

            Console.WriteLine("Now folder will be opened");
            directory.Open();

            using var watcher = new DocumentReceiver(
                      directoryToWatch: directory,
                      fileNamesToWatch: new string[] { "Паспорт.jpg", "Заявление.txt", "Фото.jpg" },
                      timeoutInSec: 20);

            watcher.Finished += WatcherOnFinished;
            watcher.Timeout  += WatcherOnTimeout;

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void Test_Document()
        {
            DocumentReceiver receiver = new DocumentReceiver();

            ICommandDocument openCommand  = new OpenCommand(receiver);
            ICommandDocument closeCommand = new CloseCommand(receiver);
            ICommandDocument saveCommand  = new SaveCommand(receiver);

            MenuOption menu = new MenuOption
                              (
                openCommand: openCommand,
                saveCommand: saveCommand,
                closeCommand: closeCommand
                              );

            menu.OpenClick();
            menu.SaveClick();
            menu.CloseClick();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            DocumentReceiver document = new DocumentReceiver();

            // The client will create the command object
            // The command object has the request  (i.e. what to do?). It also has receiver object reference.
            // The receiver object is nothing but the object which will handle the request. The command object also has the Execute method.
            // The execute method will call the receiver object method and the receiver object method will handle the request.
            ICommand openCommand  = new OpenCommand(document);
            ICommand saveCommand  = new SaveCommand(document);
            ICommand closeCommand = new CloseCommand(document);

            //As per the command design pattern, the command object will be passed to the invoker object. The Invoker does not know how to handle the request. What the invoker will do is, it will call the Execute method of the command object.
            //The execute method of command object will call the receiver object method and the receiver object method will perform the necessary action to handle the request.

            MenuOptionsInvoker menu = new MenuOptionsInvoker(openCommand, saveCommand, closeCommand);

            menu.clickOpen();
            menu.clickSave();
            menu.clickClose();
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var ev = new DocumentReceiver();

            ev.DocumentsReady += () =>
            {
                Console.WriteLine("All documents in folder");
                waitHadnle.Set();
            };

            ev.TimedOut += () =>
            {
                Console.WriteLine("Time is over");
                waitHadnle.Set();
            };

            ev.Start(PATH, INTERVAL);

            waitHadnle.WaitOne();

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Ejemplo n.º 5
0
 public SaveCommand(DocumentReceiver receiver)
 {
     _receiver = receiver;
 }
Ejemplo n.º 6
0
 public CloseCommand(DocumentReceiver receiver)
 {
     _receiver = receiver;
 }
Ejemplo n.º 7
0
 public OpenCommand(DocumentReceiver receiver)
 {
     _receiver = receiver;
 }
Ejemplo n.º 8
0
 public SaveCommand(DocumentReceiver doc)
 {
     document = doc;
 }
Ejemplo n.º 9
0
 public CloseCommand(DocumentReceiver doc)
 {
     document = doc;
 }
Ejemplo n.º 10
0
 public OpenCommand(DocumentReceiver doc)
 {
     document = doc;
 }