Exemplo n.º 1
0
        //**** client code that does not need to be changed  ***
        public static void ShipBook(IBookStore s)
        {
            //LDAF003
            IDistributor d = s.GetDistributor();

            d.ShipBook();
        }
Exemplo n.º 2
0
        //**** client code that does not need to be changed  ***

        /*
         * //LDAF007 - THE CORE
         * Notice that regardless if you pass in BookStoreA or BookStoreB into the method above, this client code does
         * not need to be changed since it will get the correct advertiser automatically using the internal logics
         * within the factories. It is the factories (BookStoreA and BookStoreB) that determines which advertiser to produce.
         * The same goes for choosing which book distributor to produce.
         *
         * The benefit of the Abstract Factory pattern is that it allows you to create a groups of products
         * (the distributors and the advertisers) without having to know the actual class of the product being produced.
         * The result is that you can have client code that does not need to be changed when  the internal logic of
         * the factories on which product to produce changed.
         */
        public static void Advertise(IBookStore s)
        {
            //LDAF004
            IAdvertiser a = s.GetAdvertiser();

            a.Advertise();
        }
Exemplo n.º 3
0
 public BooksController(IBookStore store, ImageUploader imageUploader,
                        BookDetailLookup bookDetailLookup)
 {
     _store            = store;
     _imageUploader    = imageUploader;
     _bookDetailLookup = bookDetailLookup;
 }
 public BooksController(IBookStore store, ImageUploader imageUploader,
     BookDetailLookup bookDetailLookup)
 {
     _store = store;
     _imageUploader = imageUploader;
     _bookDetailLookup = bookDetailLookup;
 }
        // [END createtopicandsubscription]

        public Task StartPullLoop(IBookStore bookStore, CancellationToken cancellationToken)
        {
            return(Task.Factory.StartNew(() => PullLoop((long bookId) =>
            {
                _logger.LogVerbose($"Processing {bookId}.");
                ProcessBook(bookStore, bookId);
            }, cancellationToken)));
        }
Exemplo n.º 6
0
        public MainPageViewModel(IPageService pageService, IBookStore bookStore)
        {
            _pageService = pageService;
            _bookStore   = bookStore;

            //PickPdfCommand = new Command(async () => await PickPdf());
            StartClickedCommand    = new Command(async() => await StartClicked());
            LibraryListPageCommand = new Command(async() => await LibraryPage());
        }
Exemplo n.º 7
0
        public LibraryListPageViewModel(IPageService pageService, IBookStore bookStore, MainPageViewModel viewModel)
        {
            FrontColor   = viewModel.FrontColor;
            BackColor    = viewModel.BackColor;
            _viewModel   = viewModel;
            _pageService = pageService;
            _bookStore   = bookStore;

            AddBookCommand    = new Command(async() => await AddBook());
            SelectBookCommand = new Command <Book>(async vm => await SelectBook(vm));
            LoadDataCommand   = new Command(async() => await LoadData());
            DeleteBookCommand = new Command <Book>(async vm => await DeleteBook(vm));
        }
Exemplo n.º 8
0
 public override void SetPrefix(string prefix)
 {
     if (DirPattern.Exist(prefix, @"[0-9][0-9][0-9][0-9]", @"([0-9][0-9][0-9][0-9])\.png"))
     {
         Global.Debugf("info", "selecting OldBookStore");
         p = new OldBookStore();
     }
     else
     {
         Global.Debugf("info", "selecting (new) BookStore");
         p = new BookStore();
     }
     p.SetPrefix(prefix);
 }
        // [END enqueuebook]

        /// <summary>
        /// Look up a book in Google's Books API.  Update the book in the book store.
        /// </summary>
        /// <param name="bookStore">Where the book is stored.</param>
        /// <param name="bookId">The id of the book to look up.</param>
        /// <returns></returns>
        // [START processbook]
        public void ProcessBook(IBookStore bookStore, long bookId)
        {
            var book = bookStore.Read(bookId);

            _logger.LogVerbose($"Found {book.Title}.  Updating.");
            var query = "https://www.googleapis.com/books/v1/volumes?q="
                        + Uri.EscapeDataString(book.Title);
            var response = WebRequest.Create(query).GetResponse();
            var reader   = new StreamReader(response.GetResponseStream());
            var json     = reader.ReadToEnd();

            UpdateBookFromJson(json, book);
            bookStore.Update(book);
        }
 /// <summary>
 /// Look up a book in Google's Books API.  Update the book in the book store.
 /// </summary>
 /// <param name="bookStore">Where the book is stored.</param>
 /// <param name="bookId">The id of the book to look up.</param>
 /// <returns></returns>
 public static void ProcessBook(IBookStore bookStore, long bookId)
 {
     var book = bookStore.Read(bookId);
     var query = "https://www.googleapis.com/books/v1/volumes?q="
         + Uri.EscapeDataString(book.Title);
     var response = WebRequest.Create(query).GetResponse();
     var reader = new StreamReader(response.GetResponseStream());
     var json = reader.ReadToEnd();
     dynamic results = JObject.Parse(json);
     dynamic info = results.items[0].volumeInfo;
     book.Title = info.title;
     book.PublishedDate = info.publishedDate;
     book.Author = string.Join(", ", info.authors);
     book.Description = info.description;
     // TODO: update image.
     bookStore.Update(book);
 }
Exemplo n.º 11
0
        //LDF002 client code does not need to be changed if the logic for choosing the distributor
        // in each BookStore will change
        public static void ShipBook(IBookStore s)
        {
            /*
             * The key is your customer should not care which distributor you choose because they will get their books
             * regardless. It is completely hidden from the customer's point of view and they should not be concerned
             * about it. You, the online bookstore, are the one that determines the distributor to use.
             */
            // the book store guy say that he need of a distributor for a specific location, but
            // he doesn't know which real distributor will be implemented.

            // FACTORY METHOD //the client gets the distributor without having to know which distributor is being used
            //LDF003 Notice that this client code don’t need to care which distributor is being created,
            //and this is the key to the factory method pattern.
            IDistributor d = s.GetDistributor();

            // IN a second time the distributor implemented will ship the book.
            d.ShipBook();
        }
        // [END enqueuebook]

        /// <summary>
        /// Look up a book in Google's Books API.  Update the book in the book store.
        /// </summary>
        /// <param name="bookStore">Where the book is stored.</param>
        /// <param name="bookId">The id of the book to look up.</param>
        /// <returns></returns>
        // [START processbook]
        public void ProcessBook(IBookStore bookStore, long bookId)
        {
            var book = bookStore.Read(bookId);
            _logger.LogVerbose($"Found {book.Title}.  Updating.");
            var query = "https://www.googleapis.com/books/v1/volumes?q="
                + Uri.EscapeDataString(book.Title);
            var response = WebRequest.Create(query).GetResponse();
            var reader = new StreamReader(response.GetResponseStream());
            var json = reader.ReadToEnd();
            UpdateBookFromJson(json, book);
            bookStore.Update(book);
        }
        // [END createtopicandsubscription]

        public Task StartPullLoop(IBookStore bookStore, CancellationToken cancellationToken)
        {
            return Task.Factory.StartNew(() => PullLoop((long bookId) =>
            {
                _logger.LogVerbose($"Processing {bookId}.");
                ProcessBook(bookStore, bookId);
            }, cancellationToken));
        }
 public AdministrationBooksController(IBookStore bookStore)
 {
     _bookStore = bookStore;
 }
 public BookController(IBookStore bookStore)
 {
     _bookStore = bookStore;
     BuyBooksOnOpening();
 }
Exemplo n.º 16
0
        private static void Advertise(IBookStore bookStore)
        {
            IAdvertiser obj = bookStore.GetAdvertiser();

            obj.Advertise();
        }
 /// <ChangeLog>
 /// <Create Datum="08.11.2020" Entwickler="DA" />
 /// </ChangeLog>
 /// <summary>
 /// Creates the presenter
 /// </summary>
 /// <param name="bookStoreView">the view to the Bookstore (the list of all books)</param>
 public BookstorePresenter(IBookStore bookStoreView)
 {
     _bookStoreView = bookStoreView;
     _service       = Commons.DependencyContainer.GetObject <Contracts.IDatabase>();
     //	service = BookService.Instance;
 }
Exemplo n.º 18
0
 public HomeController(IBookStore bookStore, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager)
 {
     _bookStore         = bookStore;
     this.signInManager = signInManager;
     this.userManager   = userManager;
 }
 public BooksController(IBookStore store, ImageUploader imageUploader)
 {
     _store = store;
     _imageUploader = imageUploader;
 }
Exemplo n.º 20
0
        //**** client code that does not need to be changed  ***
        private static void Advertise(IBookStore s)
        {
            IAdvertiser a = s.GetAdvertiser();

            a.Advertise();
        }
Exemplo n.º 21
0
 public App(IBookStore bookStore)
 {
     _bookStore = bookStore ?? throw new ArgumentNullException(nameof(bookStore));
 }
 public BooksController(IBookStore store)
 {
     _store = store;
 }
 public BooksController(IBookStore store, ImageUploader imageUploader)
 {
     _store         = store;
     _imageUploader = imageUploader;
 }
Exemplo n.º 24
0
 public BooksServiceImpl(IBookStore bookStore, IConfiguration configuration)
 {
     _bookStore     = bookStore;
     _configuration = configuration;
 }
Exemplo n.º 25
0
        private static void ShipBook(IBookStore bookStore)
        {
            IDistributor obj = bookStore.GetDistributor();

            obj.ShipBook();
        }
 public BooksController(IBookStore store)
 {
     _store = store;
 }
			public ItemService(IBookStore bookStore)
			{
				this.bookStore = bookStore;
			}
Exemplo n.º 28
0
 public ItemService(IBookStore bookStore)
 {
     this.bookStore = bookStore;
 }
Exemplo n.º 29
0
        //**** client code that does not need to be changed  ***
        private static void ShipBook(IBookStore s)
        {
            IDistributor d = s.GetDistributor();

            d.ShipBook();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="bookStore">Singleton instance of the Book Store </param>
 public BookStoreController(IBookStore bookStore)
 {
     this.mBookStore = bookStore;
 }
 public BooksController(IBookStore store, BookDetailLookup bookDetailLookup)
 {
     _store = store;
     _bookDetailLookup = bookDetailLookup;
 }
Exemplo n.º 32
0
 public BooksController(IBookStore bookStore)
 {
     _bookStore = bookStore ?? throw new ArgumentNullException(nameof(bookStore));
 }