• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Book类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: LoadSideBanner

    private void LoadSideBanner()
    {
        Book book = new Book();

        DataSet ds = new DataSet();
        ds = book.ListInteriorBooks();

        DataTable dt = new DataTable();
        dt = ds.Tables[0];

        int RowCount = dt.Rows.Count;

        if (RowCount > 0)
        {
            BookPanel.Controls.Add(new LiteralControl("<ul id=\"mycarousel\" class=\"jcarousel jcarousel-skin-tango\">"));
            for (int i = 0; i < RowCount; i++)
            {
                string control = string.Format("<li><a href=\"ViewBook.aspx?bookid={0}\">"
                    + "<img src=\"../E-Library/{1}\" width=\"150\" height=\"150\" alt=\"\" /></li>"
                        , Convert.ToString(dt.Rows[i]["bookid"]), Convert.ToString(dt.Rows[i]["imgpath"]));
                BookPanel.Controls.Add(new LiteralControl(control));
            }
            BookPanel.Controls.Add(new LiteralControl("</ul>"));
        }
    }
开发者ID:nutsukae,项目名称:E-library,代码行数:25,代码来源:home.aspx.cs


示例17: New_OrderWith3Book_Price24DescPesos

 public void New_OrderWith3Book_Price24DescPesos()
 {
     Book book = new Book() { Price = 8 };
     _orderItem.Book = _orderItem.TotalBookDesc(book, 3, .10);
     double total = _orderItem.Book.Price;
     Assert.AreEqual(22.9, Convert.ToDecimal(total.ToString(".##")));
 }
开发者ID:josegarciaalvarado,项目名称:harrypotter,代码行数:7,代码来源:OrderItemTests.cs


示例18: WriteDefaultValues

        private static void WriteDefaultValues(string fileName)
        {
            Book first = new Book("Author1", "Title1", "Pub1", 1990, 200);
            Book second = new Book("Author2", "Title2", "Pub1", 1999, 250);
            Book third = new Book("Author3", "Title3", "Pub1", 1998, 205);
            BookListService bls = new BookListService();
            bls.AddBook(first);
            bls.AddBook(second);
            bls.AddBook(third);
            
            FileStream fs = new FileStream(fileName, FileMode.Create);

            BinaryFormatter formatter = new BinaryFormatter();
            try
            {
                formatter.Serialize(fs, bls);                

            }
            catch (SerializationException e)
            {
                log.Error("Failed to serialize. Reason: " + e.Message);
                throw;
            }
            finally
            {
                fs.Close();
            }
        }
开发者ID:eduard-posmetuhov,项目名称:ASP.NET.Posmetuhov.Day5,代码行数:28,代码来源:Program.cs


示例19: EditBook

        public ActionResult EditBook(int id, Book data, bool onlyStock, int modifyStock, string plusOrMinus)
        {
            try
            {                
                if (onlyStock)
                {
                    adminService.EditStockData(id, modifyStock, plusOrMinus);
                    return RedirectToAction("ControlPanel");
                }

                if (ModelState.IsValid)
                {
                    adminService.EditBookData(id, data, modifyStock, plusOrMinus);
                    return RedirectToAction("ControlPanel");
                }

                throw new Exception();
            }
            catch (Exception ex)
            {
                if (ex.InnerException is SqlException)
                {
                    ViewBag.EditError = ex.InnerException.Message;
                    return View(data);
                }

                return View(data);
            }
        }
开发者ID:gustavo-vasquez,项目名称:LibraryProyect,代码行数:29,代码来源:AdministratorController.cs


示例20: Main

        static void Main(string[] args)
        {
            Book book = new Book() { Id = 1, Title = "Book 1", Author = "Author 1" };
            book.Save(book);

            Console.Read();
        }
开发者ID:fatkhanfauzi,项目名称:CSharp-SOLID-Principle-Examples,代码行数:7,代码来源:WrongExProgram.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Booking类代码示例发布时间:2022-05-24
下一篇:
C# Boo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap