当前位置: 首页>>代码示例>>C#>>正文


C# Book类代码示例

本文整理汇总了C#中Book的典型用法代码示例。如果您正苦于以下问题:C# Book类的具体用法?C# Book怎么用?C# Book使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Book类属于命名空间,在下文中一共展示了Book类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindBooksByName

        private static void FindBooksByName(string substring)
        {
            Console.WriteLine("\nFinding books by name '{0}':", substring);

            SQLiteCommand mySqlCommand = new SQLiteCommand(@"SELECT Title, Author, PublishDate, ISBN
                                                             FROM Books
                                                             WHERE CHARINDEX(@substring, Title)", mySqlConnection);

            mySqlCommand.Parameters.AddWithValue("@substring", substring);

            using (SQLiteDataReader reader = mySqlCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    var title = reader["Title"].ToString();
                    var author = reader["Author"].ToString();
                    var publishDate = (DateTime)reader["PublishDate"];
                    var isbn = reader["ISBN"].ToString();

                    var book = new Book()
                    {
                        Title = title,
                        Author = author,
                        PublishDate = publishDate,
                        ISBN = isbn
                    };

                    Console.WriteLine(book);
                }
            }
        }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:31,代码来源:WorkingWithSQLite.cs

示例2: PutBook

        public async Task<IHttpActionResult> PutBook(int id, Book book)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != book.Id)
            {
                return BadRequest();
            }

            db.Entry(book).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
开发者ID:sam-glad,项目名称:BookService,代码行数:32,代码来源:BooksController.cs

示例3: Print

        private static void Print(IFormatter formatter)
        {
            List<Publication> documents = new List<Publication>();

            var newspaper = new Newspaper(formatter);
            newspaper.Title = "The Publicist";
            newspaper.Articles.Add("Sugar linked to bad eyesight", "Rod Sugar");
            newspaper.Articles.Add("Sweden bans chocolate", "Willy Wonka");
            newspaper.Articles.Add("Opera house to be painted orange", "Orange Arup");
            documents.Add(newspaper);

            var book = new Book(formatter)
            {
                Title = "Price of Silence",
                Author = "Jay and Silent Bob",
                Text = "Blah-de-blah-de-blah..."
            };

            documents.Add(book);

            var magazine = new Magazine(formatter)
            {
                Name = "MixMag",
                PrintDate = "30/08/1993",
                CoverHeadline = "Downloads outstrip CD sales"
            };

            documents.Add(magazine);

            foreach (var doc in documents)
            {
                doc.Print();
            }
        }
开发者ID:Maceage,项目名称:DesignPatterns,代码行数:34,代码来源:Program.cs

示例4: Add

 public void Add(Book b)
 {
     if (b == null)
         throw new ArgumentNullException("Book cannot be null.");
     //
     this.Books.Add(b);
 }
开发者ID:bernardobrezende,项目名称:IntroDotNetCSharp,代码行数:7,代码来源:BookCollection.cs

示例5: OpenBook

 private static void OpenBook(Book book)
 {
     Process proc = new Process();
     proc.EnableRaisingEvents = false;
     proc.StartInfo.FileName = book.Path;
     proc.Start();
 }
开发者ID:gedgei,项目名称:BookDbSharp,代码行数:7,代码来源:MainForm.cs

示例6: Main

 static void Main()
 {
     Book readyPlayerOne = new Book("Ready Player One", "Ernest Cline", 16.90);
     Console.WriteLine(readyPlayerOne.ToString());
     GoldenEditionBook fahrenheit = new GoldenEditionBook("Fahrenheit 451", "Ray Bradbury", 11.90);
     Console.WriteLine(fahrenheit.ToString());
 }
开发者ID:krasi070,项目名称:OOP,代码行数:7,代码来源:BookShop.cs

示例7: AddBook

 public Book AddBook(Book book)
 {
     var query = Ninject.Get<InsertBookQuery>();
     query.Book = book;
     query.Execute();
     return book;
 }
开发者ID:BlackieLawless,项目名称:Library,代码行数:7,代码来源:BibliographerService.cs

示例8: Handle

 public static bool Handle(EndpointRegistration endpointRegistration, IRequestInfo info, CollectionSettings collectionSettings, Book.Book currentBook)
 {
     var request = new ApiRequest(info, collectionSettings, currentBook);
     try
     {
         if(Program.RunningUnitTests)
         {
             endpointRegistration.Handler(request);
         }
         else
         {
             var formForSynchronizing = Application.OpenForms.Cast<Form>().Last();
             if (endpointRegistration.HandleOnUIThread && formForSynchronizing.InvokeRequired)
             {
                 formForSynchronizing.Invoke(endpointRegistration.Handler, request);
             }
             else
             {
                 endpointRegistration.Handler(request);
             }
         }
         if(!info.HaveOutput)
         {
             throw new ApplicationException(string.Format("The EndpointHandler for {0} never called a Succeeded(), Failed(), or ReplyWith() Function.", info.RawUrl.ToString()));
         }
     }
     catch (Exception e)
     {
         SIL.Reporting.ErrorReport.ReportNonFatalExceptionWithMessage(e, info.RawUrl);
         return false;
     }
     return true;
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:33,代码来源:ApiRequest.cs

示例9: Main

    static void Main(string[] args)
    {
        Book firstBook = new Book("C#", "Svetlin Nakov");
        Book secondBook = new Book("Java", "Svetlin Nakov");
        Book thirdBook = new Book(".NET", "Svetlin Nakov");
        Book fourthBook = new Book("Ice and fire", "George Martin");

        Library telerikLib = new Library("Telerik Library");
        
        
        telerikLib.Add(firstBook);
        telerikLib.Add(secondBook);
        telerikLib.Add(thirdBook);
        telerikLib.Add(fourthBook);
        Console.WriteLine("Display library :");
        telerikLib.DisplayAll();

        int startIndx = 0;
        int indxFound;

        while (telerikLib.IndexOf("Svetlin Nakov", startIndx, SearchOption.Author) != -1)
        {
            indxFound = telerikLib.IndexOf("Svetlin Nakov", startIndx, SearchOption.Author);
            telerikLib.DeleteAt(indxFound);
        }
        Console.WriteLine("\nAfter deleting :");
        telerikLib.DisplayAll();
    }
开发者ID:VaniaStoicheva,项目名称:Library,代码行数:28,代码来源:TestLibrary.cs

示例10: Start

    // Use this for initialization
    void Start () {
        if (!ControledBook)
            ControledBook = GetComponent<Book>();
        if (AutoStartFlip)
            StartFlipping();
        ControledBook.OnFlip.AddListener(new UnityEngine.Events.UnityAction(PageFlipped));
	}
开发者ID:Dandarawy,项目名称:Unity3DBookPageCurl,代码行数:8,代码来源:AutoFlip.cs

示例11: ApiRequest

 public ApiRequest(IRequestInfo requestinfo, CollectionSettings currentCollectionSettings, Book.Book currentBook)
 {
     _requestInfo = requestinfo;
     CurrentCollectionSettings = currentCollectionSettings;
     CurrentBook = currentBook;
     Parameters = requestinfo.GetQueryParameters();
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:7,代码来源:ApiRequest.cs

示例12: BuildBooks

        protected void BuildBooks()
        {
            PageRepository.DeleteAll();
              BookRepository.DeleteAll();

              Console.WriteLine("Add books");

              Book b = new Book("mexikansk-mad", "Mexikansk mad", "En samling af mine yndlingsopskrifter fra Mexiko",
                        TestDataConstants.Profiles.SimonProfileId);
              b.PublishedDate = DateTime.UtcNow;

              Page p1 = new TextPage("Velbekomme", 1, "Demo");
              PageRepository.Add(p1);
              b.AddPage(p1.Id);

              RecipePage p2 = new RecipePage(MexicanskeBurritosRecipe.Title, 2, MexicanskeBurritosRecipe.Id);
              PageRepository.Add(p2);
              b.AddPage(p2.Id);

              RecipePage p3 = new RecipePage(BonneMosRecipe.Title, 3, BonneMosRecipe.Id);
              PageRepository.Add(p3);
              b.AddPage(p3.Id);

              BookRepository.Add(b);
        }
开发者ID:JornWildt,项目名称:Peach,代码行数:25,代码来源:TestDataBuilder.cs

示例13: ShouldAddAndRemoveCoverFromBook

        public void ShouldAddAndRemoveCoverFromBook()
        {
            Book book = new Book
                {
                    CategoryId = 1,
                    Title = "Book title",
                    Author = "pawel",
                    AdditionalInfoLine1 = "Additional Info",
                    ISBN = "222226"
                };

            Bitmap bitmap = new Bitmap(4, 4);
            for (int x = 0; x < bitmap.Height; ++x)
                for (int y = 0; y < bitmap.Width; ++y)
                    bitmap.SetPixel(x, y, Color.Red);

            book.Cover = bitmap;

            var status = BooksManager.InsertBook(book);
            Assert.Greater(book.Id, 0);
            Assert.IsNotNull(status.Data.Cover);

            status.Data.Cover = null;
            var status2 = BooksManager.UpdateBook(book);
            Assert.AreEqual(status2.Result, OperationResult.Passed);

            var bookWithNoCover = BooksManager.GetBook(book.Id);
            Assert.IsNull(bookWithNoCover.Cover);
        }
开发者ID:pawelklimczyk,项目名称:BookHouse,代码行数:29,代码来源:ManagerTests.cs

示例14: BooksInDeletedCategoryShouldBeVisibleInMainCategory

        public void BooksInDeletedCategoryShouldBeVisibleInMainCategory()
        {
            string isbn = "347563487562347856";
            Category newCategory = new Category
            {
                Name = "Category to delete",
                Parent = BooksManager.GetCategoryList(Constants.ROOT_CATEGORY, false)[0]
            };

            var result = BooksManager.InsertCategory(newCategory);

            Book newBook = new Book
                {
                    CategoryId = result.Data.Id,
                    Title = "Book title",
                    Author = "pawel",
                    AdditionalInfoLine1 = "Additional Info",
                    ISBN = isbn
                };

            BooksManager.InsertBook(newBook);

            BooksManager.DeleteCategory(newCategory);
            var books = BooksManager.GetBooksList(new BookFilter { ISBN = isbn });
            Assert.AreEqual(books.Count, 1);
            Assert.IsNull(books[0].Category);
        }
开发者ID:pawelklimczyk,项目名称:BookHouse,代码行数:27,代码来源:ManagerTests.cs

示例15: New_OrderWith2Book_Price16Pesos

 public void New_OrderWith2Book_Price16Pesos()
 {
     Book book = new Book() { Price = 8 };
     _orderItem.Book = _orderItem.TotalBook(book, 2);
     double total = _orderItem.Book.Price;
     Assert.AreEqual(16, total);
 }
开发者ID:josegarciaalvarado,项目名称:harrypotter,代码行数:7,代码来源:OrderItemTests.cs


注:本文中的Book类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。