Example #1
0
        static void Main(string[] args)
        {
            OrdinarBookFactory    ordinarFactory    = new OrdinarBookFactory();
            CollectionBookFactory collectionFactory = new CollectionBookFactory();

            Book ordinarBook = ordinarFactory.MakeBook("Кац Яков Михайлович",
                                                       "Шушпанов Аркадий Васильевич",
                                                       "Черногорская Маринна Витальевна",
                                                       "Параноидальное танго");

            Book collectionBook = collectionFactory.MakeBook("Клин Клим Климович",
                                                             "Берестов Демьян Прокофьевич",
                                                             "Факторович Леонид Львович",
                                                             "Эволюция. Тщетность.");

            Book collectionBook1 = collectionFactory.MakeBook("Клин Клим Климович",
                                                              "Берестов Демьян Прокофьевич",
                                                              "Факторович Леонид Львович",
                                                              "Alpha.");

            PublishingOffice <IBook> office = new PublishingOffice <IBook>("Буква")
            {
                ordinarBook,
                collectionBook,
                collectionBook1
            };

            Console.WriteLine("По названию:");
            office.SortBooks(Comparators.SortByTitle);
            office.PrintBooks();
            Console.WriteLine("По году издания:");
            office.SortBooks(Comparators.SortByPublicationYear);
            office.PrintBooks();
            Console.WriteLine("По году издания в обратном порядке:");
            office.SortBooks(Comparators.SortByPublicationYearDesc);
            office.PrintBooks();


            office.HireActorWithReward(new Writer <IReward>("Василий Сергеевич Чесноков", new Reward(300000)));
            office.HireActorWithWage(new Publisher <IWage>("Николай Александрович Клим", new Wage(30000, 31)));
            office.PrintMembers();
            office.InteractWithActors(riseSalary);
            office.PrintMembers();

            office.CountBooks(countCollectionBooks);

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Logger <IBook> logger = new Logger <IBook>();

            logger.OnLog += Logger_OnLog;
            OrdinarBookFactory    ordinarFactory    = new OrdinarBookFactory(logger);
            CollectionBookFactory collectionFactory = new CollectionBookFactory(logger);

            Book ordinarBook = ordinarFactory.MakeBook("Кац Яков Михайлович",
                                                       "Шушпанов Аркадий Васильевич",
                                                       "Черногорская Маринна Витальевна",
                                                       "Параноидальное танго");

            Book collectionBook = collectionFactory.MakeBook("Клин Клим Климович",
                                                             "Берестов Демьян Прокофьевич",
                                                             "Факторович Леонид Львович",
                                                             "Эволюция. Тщетность.");
        }
Example #3
0
        static void Main(string[] args)
        {
            OrdinarBookFactory    ordinarFactory    = new OrdinarBookFactory();
            CollectionBookFactory collectionFactory = new CollectionBookFactory();

            Book ordinarBook = ordinarFactory.MakeBook("Кац Яков Михайлович",
                                                       "Шушпанов Аркадий Васильевич",
                                                       "Черногорская Маринна Витальевна",
                                                       "Параноидальное танго");

            Book collectionBook = collectionFactory.MakeBook("Клин Клим Климович",
                                                             "Берестов Демьян Прокофьевич",
                                                             "Факторович Леонид Львович",
                                                             "Эволюция. Тщетность.");

            Console.WriteLine(ordinarBook.ToString());
            Console.WriteLine();
            Console.WriteLine(collectionBook.ToString());
            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            string projectPath = "..\\..\\";
            Logger logger      = new Logger(6, Path.Combine(projectPath, "log.txt"));

            logger.OnLog += Logger_OnLog;
            OrdinarBookFactory factory = new OrdinarBookFactory(logger);

            PublishingOffice <Book> office = new PublishingOffice <Book>("Буква");

            //Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
            Console.WriteLine("Генерация книг");
            for (int i = 0; i < 3; i++)
            {
                office.Add(factory.MakeBook("Кац Яков Михайлович",
                                            "Шушпанов Аркадий Васильевич",
                                            "Черногорская Маринна Витальевна",
                                            $"Книга {i}"));
            }
            Console.WriteLine("Генерация завершена\n");

            BinaryPubOfficeSerializer <Book> binSerializer  = new BinaryPubOfficeSerializer <Book>();
            JSONPubOfficeSerializer <Book>   jsonSerializer = new JSONPubOfficeSerializer <Book>();
            XMLPubOfficeSerializer <Book>    xmlSerializer  = new XMLPubOfficeSerializer <Book>();

            PublishingOffice <Book> evilOffice = new PublishingOffice <Book>();

            evilOffice = jsonSerializer.Deserialize(Path.Combine(projectPath, "office_input.json"));
            //evilOffice = xmlSerializer.Deserialize(Path.Combine(projectPath, "office_input.xml"));
            //evilOffice = binSerializer.Deserialize(Path.Combine(projectPath, "office_input.bin"));

            jsonSerializer.Serialize(evilOffice, Path.Combine(projectPath, "office_output.json")); // проверка

            binSerializer.Serialize(office, Path.Combine(projectPath, "office.bin"));
            jsonSerializer.Serialize(office, Path.Combine(projectPath, "office.json"));
            xmlSerializer.Serialize(office, Path.Combine(projectPath, "office.xml"));

            //office.SortBooksAsync(Comparators.SortByPublicationYear,
            //    (progressProcs, book) => Console.WriteLine($"Процент сортировки: {progressProcs}%\nКнига: {book}\n")).Wait();
        }
Example #5
0
        static void Main(string[] args)
        {
            string projectPath = "..\\..\\";
            Logger logger      = new Logger(Path.Combine(projectPath, "log.txt"));

            logger.OnLog += Logger_OnLog;
            OrdinarBookFactory factory = new OrdinarBookFactory(logger);

            PublishingOffice <IBook> office = new PublishingOffice <IBook>("Буква");

            Console.WriteLine("Генерация книг");
            for (int i = 0; i < 1000; i++)
            {
                office.Add(factory.MakeBook("Кац Яков Михайлович",
                                            "Шушпанов Аркадий Васильевич",
                                            "Черногорская Маринна Витальевна",
                                            $"Книга {i}"));
            }
            Console.WriteLine("Генерация завершена\n");
            office.SortBooksAsync(Comparators.SortByPublicationYear,
                                  (progressProcs, book) => Console.WriteLine($"Процент сортировки: {progressProcs}%\nКнига: {book}\n")).Wait();
        }
Example #6
0
        static void Main(string[] args)
        {
            OrdinarBookFactory    ordinarFactory    = new OrdinarBookFactory();
            CollectionBookFactory collectionFactory = new CollectionBookFactory();

            Book ordinarBook = ordinarFactory.MakeBook("Кац Яков Михайлович",
                                                       "Шушпанов Аркадий Васильевич",
                                                       "Черногорская Маринна Витальевна",
                                                       "Параноидальное танго");

            Book collectionBook = collectionFactory.MakeBook("Клин Клим Климович",
                                                             "Берестов Демьян Прокофьевич",
                                                             "Факторович Леонид Львович",
                                                             "Эволюция. Тщетность.");

            PublishingOffice <IBook> office = new PublishingOffice <IBook>("Буква")
            {
                ordinarBook,
                collectionBook
            };

            office.PrintBooks();
            Console.WriteLine($"Удалим одну книгу");
            office.Remove(ordinarBook);
            office.PrintBooks();
            Console.WriteLine();

            office.HireActorWithReward(new Writer <IReward>("Василий Сергеевич Чесноков", new Reward(300000)));
            office.HireActorWithWage(new Publisher <IWage>("Николай Александрович Клим", new Wage(30000, 31)));
            office.PrintMembers();

            IContractProvider <IPerson>           personContract = new PublishingOffice <IBook>("Эксмо");
            IContractProvider <IActor <ISalary> > actorContract  = personContract;

            actorContract.PrintContract(new Publisher <IWage>("Юлия Львовна Липская", new Wage(7000, 7)));

            Console.ReadLine();
        }