本文整理汇总了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);
}
}
}
示例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);
}
示例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();
}
}
示例4: Add
public void Add(Book b)
{
if (b == null)
throw new ArgumentNullException("Book cannot be null.");
//
this.Books.Add(b);
}
示例5: OpenBook
private static void OpenBook(Book book)
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = book.Path;
proc.Start();
}
示例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());
}
示例7: AddBook
public Book AddBook(Book book)
{
var query = Ninject.Get<InsertBookQuery>();
query.Book = book;
query.Execute();
return book;
}
示例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;
}
示例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();
}
示例10: Start
// Use this for initialization
void Start () {
if (!ControledBook)
ControledBook = GetComponent<Book>();
if (AutoStartFlip)
StartFlipping();
ControledBook.OnFlip.AddListener(new UnityEngine.Events.UnityAction(PageFlipped));
}
示例11: ApiRequest
public ApiRequest(IRequestInfo requestinfo, CollectionSettings currentCollectionSettings, Book.Book currentBook)
{
_requestInfo = requestinfo;
CurrentCollectionSettings = currentCollectionSettings;
CurrentBook = currentBook;
Parameters = requestinfo.GetQueryParameters();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}