private void deleteShelfButton_Click(object sender, EventArgs e)//删除书架 { BookShelf shelf = shelfBindingSource.Current as BookShelf; BookShelfService.RemoveBookShelf(shelf.BookShelfId); shelfBindingSource.DataSource = BookShelfService.GetAllShelfs(); }
void TouchAndVerify(BookShelf data, int nExpectedBooks, int optionalPayloadDataSize) { if (!VerifyAndTouch) { return; } string tmpTitle = null; int tmpId = 0; if (nExpectedBooks != data.Books.Count) { throw new InvalidOperationException($"Number of deserialized Books was {data.Books.Count} but expected {nExpectedBooks}. This Serializer seem to have lost data."); } for (int i = 0; i < data.Books.Count; i++) { tmpTitle = data.Books[i].Title; tmpId = data.Books[i].Id; if (data.Books[i].Id != i + 1) { throw new InvalidOperationException($"Book Id was {data.Books[i].Id} but exepcted {i + 1}"); } if (optionalPayloadDataSize > 0 && data.Books[i].BookData.Length != optionalPayloadDataSize) { throw new InvalidOperationException($"BookData length was {data.Books[i].BookData.Length} but expected {optionalPayloadDataSize}"); } } }
public async Task <ActionResult <BookShelf> > PostBookShelf(BookShelf bookShelf) { _context.BookShelf.Add(bookShelf); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetBookShelf), new { id = bookShelf.BookShelfId }, bookShelf)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,BookShelfName,Description,CreateByUserId")] BookShelf bookShelf) { if (id != bookShelf.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bookShelf); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookShelfExists(bookShelf.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CreateByUserId"] = new SelectList(_context.Users, "Id", "Id", bookShelf.CreateByUserId); return(View(bookShelf)); }
// 部分兑现修改值 public void PartialGetInfo(BookShelf shelf) { if (GetTextValue(this.textBox_roomName.Text) != null) { shelf.RoomName = GetTextValue(this.textBox_roomName.Text); } if (GetTextValue(this.textBox_shelfNo.Text) != null) { shelf.No = GetTextValue(this.textBox_shelfNo.Text); } if (GetTextValue(this.textBox_accessNoRange.Text) != null) { shelf.AccessNoRange = GetTextValue(this.textBox_accessNoRange.Text); } if (GetTextValue(this.textBox_color.Text) != null) { // TODO: 是否要验证一下颜色值? shelf.ColorString = GetTextValue(this.textBox_color.Text); } double v = 0; bool bRet = false; if (GetTextValue(this.textBox_locationX.Text) != null) { bRet = double.TryParse(this.textBox_locationX.Text, out v); if (bRet == false) { throw new Exception("位置 X 值 '" + this.textBox_locationX.Text + "' 格式错误"); } shelf.LocationX = v; } if (GetTextValue(this.textBox_locationZ.Text) != null) { v = 0; bRet = double.TryParse(this.textBox_locationZ.Text, out v); if (bRet == false) { throw new Exception("位置 Z 值 '" + this.textBox_locationZ.Text + "' 格式错误"); } shelf.LocationZ = v; } if (GetTextValue(this.textBox_direction.Text) != null) { v = 0; bRet = double.TryParse(this.textBox_direction.Text, out v); if (bRet == false) { throw new Exception("方向 值 '" + this.textBox_direction.Text + "' 格式错误"); } shelf.Direction = v; } }
public void GetInfo(BookShelf shelf) { shelf.RoomName = this.textBox_roomName.Text; shelf.No = this.textBox_shelfNo.Text; shelf.AccessNoRange = this.textBox_accessNoRange.Text; shelf.ColorString = this.textBox_color.Text; double v = 0; bool bRet = double.TryParse(this.textBox_locationX.Text, out v); if (bRet == false) { throw new Exception("位置 X 值 '" + this.textBox_locationX.Text + "' 格式错误"); } shelf.LocationX = v; v = 0; bRet = double.TryParse(this.textBox_locationZ.Text, out v); if (bRet == false) { throw new Exception("位置 Z 值 '" + this.textBox_locationZ.Text + "' 格式错误"); } shelf.LocationZ = v; v = 0; bRet = double.TryParse(this.textBox_direction.Text, out v); if (bRet == false) { throw new Exception("方向 值 '" + this.textBox_direction.Text + "' 格式错误"); } shelf.Direction = v; }
/// <summary> /// 現在フォーカスされているオブジェクトの、次のオブジェクトを返却する /// </summary> /// <returns>オブジェクト</returns> public object Next() { Book book = BookShelf.GetBookAt(Index); this.Index++; return(book); }
// コンソールアプリケーションで実行を確認しました static void Main(string[] args) { BookShelf bookShelf = new BookShelf(); bookShelf.appendBook(new Book("Around the world in 80 days")); bookShelf.appendBook(new Book("Bible")); bookShelf.appendBook(new Book("Cinderella")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); IIterator it = bookShelf.Iterator(); while (it.HasNext()) { Book book = (Book)it.Next(); Console.WriteLine(book.Name); } // 実行結果 // Around the world in 80 days // Bible // Cinderella // Daddy-Long-Legs // 実行が一瞬で終わって確認できないので、キーの入力を待ちます Console.ReadLine(); }
protected override T Deserialize(Stream stream) { T lret = default; if (typeof(BookShelf) == typeof(T)) { var tmp = new BookShelf("This is secret") { Books = new List <Book>() }; var books = tmp.Books; // This will test basically the allocation performance of .NET which will when the allocation rate becomes too high put // Thread.Sleeps into the allocation calls. for (int i = 0; i < myCount; i++) { books.Add(new Book() { Id = i + 1, Title = Encoding.UTF8.GetString(myUtf8Data, (int)myStartIdxAndLength[i * 2], (int)myStartIdxAndLength[i * 2 + 1]) }); } lret = (T)(object)tmp; } else { throw new NotSupportedException("This class is only meant to be used with Bookshelf objects"); } return(lret); }
public async void Open(BookDataBrief book) { using (var bs = BookShelf.Create()) { var dc = SearchResult[book]; var existBook = await bs.Books.FirstOrDefaultAsync(b => b.Title == book.Title && b.Author == book.Author && b.PackageFamilyName == dc.PackageFamilyName && b.ExtensionId == dc.ExtensionId); if (existBook is null) { existBook = new Book(book, dc); bs.Books.Add(existBook); } else { existBook.Update(book, dc); } await bs.SaveChangesAsync(); await Navigator.GetForCurrentView().NavigateAsync(typeof(BookPage), existBook.Id.ToString()); } }
public async Task InitAsync(StoreAccess storeAccess) { int tryCount = 0; Books.Clear(); _storeAccess = storeAccess; try { try { tryCount++; BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess); }catch (Exception ex) { tryCount++; await Task.Delay(1000).ConfigureAwait(false); BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess); } foreach (var bookReference in BookShelf.Content) { var bookVM = await BookViewModel.CreateAsync(_bookService, _eventAggregator, bookReference); Books.Add(bookVM); } } catch (NoBookShelfExistsException ex) { _eventAggregator.GetEvent <NoBookShelfExistsMessage>().Publish(new Tuple <StoreAccess, string>(storeAccess, ex.Message + " - " + ex.AccessGrant + " - " + ex.AdditionalError + " - " + ex.StoreKey + " - " + tryCount.ToString() + " - " + ex.StackTrace)); } }
public static void ProcessTransform(Transform transform, GameObject WhoBy, bool RefreshHierarchy = false) { if (Librarian.library.TransformToBookShelves.Count == 0) { Librarian.library.TraverseHierarchy(); RefreshHierarchy = true; } Librarian.Library.LibraryBookShelf BookShelf; if (Librarian.TransformToBookShelf.ContainsKey(transform)) { BookShelf = Librarian.TransformToBookShelf[transform]; } else { BookShelf = Librarian.Library.LibraryBookShelf.PartialGenerateLibraryBookShelf(transform); } BookShelf.PopulateBookShelf(); SendBookShelfToClient(BookShelf, WhoBy); if (RefreshHierarchy) { LibraryNetMessage.Send(Librarian.library, WhoBy); } }
public async Task <bool> AddBookShelf(BookShelf book) { var userId = User.Claims.Where(a => a.Type == "UserId").Select(a => a.Value); var a = book; return(true); }
public void loadData() { AmazonDynamoDBClient client = new AmazonDynamoDBClient(Amazon.RegionEndpoint.USEast2); Table table = Table.LoadTable(client, "Users"); string email = TxtUserEmail.Text; string password = TxtPassword.Password; if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { MessageBox.Show("Fields can't be empty!", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { Document doc = table.GetItem(email); string emailInput = doc.Values.ElementAt(1); string userPasword = doc.Values.ElementAt(0); string result = emailInput; string pass = userPasword; if (email == result & password == pass) { bookShelf = new BookShelf(); this.bookShelf.UserEmail = emailInput; HomePage homePage = new HomePage(this.bookShelf); homePage.Show(); this.Close(); } else { MessageBox.Show("Incorrect Email or Password entered!"); } } }
public BookBase(ref BookShelf currentShelf, string user) { InitializeComponent(); this.currentShelf = currentShelf; CurrentUser = user; LoadBooks(); }
public bool UpdateBookShelf(BookShelf bookShelf) { bookShelf.IsDeleted = false; _unitOfWork.BookShelfRepository.Update(bookShelf); _unitOfWork.SaveChanges(); return(true); }
private void CreateSampleData() { this.bookShelf = new BookShelf(); this.bookShelf.Books.Add( new Book { Title = "Kafka On The Shore", Author = "Haruki Murakami", Price = 300, Publisher = new Publisher { Name = "Kodansha", PublisherType = PublisherType.Company } }); this.bookShelf.Books.Add( new Book { Title = "Norwegian Wood", Author = "Haruki Murakami", Price = 500, Publisher = new Publisher { Name = "Kodansha", PublisherType = PublisherType.Company } }); }
private void QueryBooksList(DynamoDBContext context) { string tabName = "BookShelf"; List <string> currentTables = client.ListTables().TableNames; if (currentTables.Contains(tabName)) { IEnumerable <BookShelf> ownedBooksResult; ownedBooksResult = context.Scan <BookShelf>( new ScanCondition("UserEmail", ScanOperator.Equal, loggedinUserId)); Console.WriteLine("List retrieved " + ownedBooksResult); foreach (var result in ownedBooksResult) { if (result != null) { BookShelf newShelf = new BookShelf() { BookId = result.BookId, BookTitle = result.BookTitle, IsActive = result.IsActive, ISBN = result.ISBN, Author1 = result.Author1, Author2 = result.Author2, Author3 = result.Author3, UserEmail = result.UserEmail, }; booksList.Add(newShelf); } lstBooks.ItemsSource = null; lstBooks.ItemsSource = booksList; } } }
private void addBookButton_Click(object sender, EventArgs e)//添加书籍 { BookShelf shelf = shelfBindingSource.Current as BookShelf; FormDetail formDetail = new FormDetail(this, shelf, currentClient); this.Hide(); formDetail.ShowDialog(); }
public BookShelfContent(BookShelf bookShelf, string user) { InitializeComponent(); DisplayedShelf = bookShelf; Title = DisplayedShelf.Name; CurrentUser = user; LoadBooks(); }
private static BookOnShelfDocument Map(BookOnShelf bookOnShelf, Book book, BookShelf bookShelf) { var document = Mapper.Map <BookOnShelfDocument>(bookOnShelf); document.Book = Mapper.Map <BookDocument>(book); document.BookShelf = Mapper.Map <BookShelfDocument>(bookShelf); return(document); }
private void ListViewBookShelfCollection_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { selectedShelf = user.ShelfCollection.ElementAt(((ListView)sender).SelectedIndex).Value; TextBoxBookShelfName.Text = selectedShelf.Name; } catch { } }
private void detailButton_Click(object sender, EventArgs e)//修改细节 { BookShelf shelf = shelfBindingSource.Current as BookShelf; Book book = bookBindingSource.Current as Book; FormDetail formDetail = new FormDetail(this, book, currentClient); this.Hide(); formDetail.ShowDialog(); }
public AddSnapshot(BookShelf book) { InitializeComponent(); snapshot = new Snapshot(); bookShelf = book; context = new DynamoDBContext(); TxtBookTitle.IsEnabled = false; TxtBookTitle.Text = book.BookTitle; }
BookShelf Data(int nToCreate) { var lret = new BookShelf("private member value"); lret.Books = Enumerable.Range(1, nToCreate).Select(i => new Book { Id = i, Title = $"Book {i}" }).ToList(); return(lret); }
public static BookShelf PopulateBookShelf(BookShelf bookShelf) { if (!bookShelf.IsPartiallyGenerated) { return(bookShelf); } MonoBehaviour[] scriptComponents = bookShelf.Shelf.GetComponents <MonoBehaviour>(); //Logger.Log(scriptComponents.Length + "leit !!!"); foreach (MonoBehaviour mono in scriptComponents) { if (mono != null) { bookShelf.HeldBooks.Add(PartialGeneratebook(mono)); } } Transform[] ts = bookShelf.Shelf.GetComponentsInChildren <Transform>(); foreach (Transform child in ts) { if (child != ts[0]) { if (child.parent == bookShelf.Shelf.transform) { BookShelf _bookShelf; _bookShelf = PartialGeneratebookShelf(child); bookShelf.ObscuredBookShelves.Add(_bookShelf); } } } Transform _Transform = bookShelf.Shelf.transform.parent; if (_Transform != null) { bookShelf.ObscuredBy = PartialGeneratebookShelf(_Transform); } else { if (TopSceneBookshelf == null) { List <BookShelf> BookShelfs = new List <BookShelf>(); foreach (var game in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()) { var _bookShelf = PartialGeneratebookShelf(game.transform); BookShelfs.Add(_bookShelf); } TopSceneBookshelf = GenerateCustomBookCase(BookShelfs); } bookShelf.ObscuredBy = TopSceneBookshelf; if (!TopSceneBookshelf.ObscuredBookShelves.Contains(bookShelf)) { TopSceneBookshelf.ObscuredBookShelves.Add(bookShelf); } } bookShelf.IsPartiallyGenerated = false; return(bookShelf); }
private ReadVM(int bookId) { using (var bs = BookShelf.Create()) { this._Book = bs.Books.Find(bookId); bs.Chapters.Where(c => c.BookId == bookId).OrderBy(c => c.ChapterId).Load(); this._BookView = this._Book.ChaptersData.CreateView(); this._BookView.CurrentChanged += this._BookView_CurrentChanged; } }
public DisplaySnapShot(BookShelf bookShelf) { InitializeComponent(); snapshotList = new List <Snapshot>(); bshelf = bookShelf; userEmail = bshelf.UserEmail; context = new DynamoDBContext(); client = new AmazonDynamoDBClient(); GetSnapshots(context); }
public void ShouldBeEmptyWhenNoBookAdded() { //Given BookShelf shelf = new BookShelf(); //When List <string> books = shelf.GetAllBooks(); //Then Assert.Empty(books); }
// Constructor public MainPage() { //calling constructor bookshelf = new BookShelf(); InitializeComponent(); //link for data to GUI listBox1.DataContext = bookshelf; // Set the data context of the listbox control to the sample data DataContext = App.ViewModel; }
public void Init() { _storeAccess = new StoreAccess("use this access"); _bookShelf = new BookShelf { OwnerName = "Mine" }; _bookServiceMock = new Moq.Mock <IBookService>(); _bookShelfServiceMock = new Moq.Mock <IBookShelfService>(); _eventAggregator = new Moq.Mock <IEventAggregator>(); _viewModel = new CreateBookViewModel(_bookServiceMock.Object, _bookShelfServiceMock.Object, _eventAggregator.Object); }
public ActionResult Create(BookShelf book) { //try //{ _bookshelfRepository.SaveOrUpdate(book); return RedirectToAction("Index"); //} //catch (Exception exception) //{ // TempData["warning"] = exception.Message; // return View(); //} }
static void Main() { BookShelf bookShelf = new BookShelf(); bookShelf.AppendBook( new Book( "Around the World in 80 Days" ) ); bookShelf.AppendBook( new Book( "Bible" ) ); bookShelf.AppendBook( new Book( "Cinderella" ) ); bookShelf.AppendBook( new Book( "Daddy-Long-Legs" ) ); Iterator it = bookShelf.Iterator(); while( it.HasNext() ) { Book book = ( Book )it.Next(); System.Console.WriteLine( book.name ); } }
static void Main(string[] args) { BookComponent tinGoyendaSeries = new BookType("TinGoyenda", "Written by Rokib Hasan"); BookComponent masudRana = new BookType("MasudRana", "Written by Kazi Anawar Hossain"); BookComponent robindroNath = new BookType("RobindroNath", "Written by Robindro Nath Tagor"); BookComponent allBooks = new BookType("Book List", "All available books"); allBooks.Add(robindroNath); robindroNath.Add(new Book("Gitanjoli", "Robindro Nath Tagor", 1905)); robindroNath.Add(new Book("GolpoGuccho", "Robindro Nath Tagor", 1908)); allBooks.Add(masudRana); masudRana.Add(new Book("Varot Nattoyom", "Kazi Anawar Hossain", 1967)); masudRana.Add(new Book("Agni Purush", "Kazi Anawar Hossain", 1969)); allBooks.Add(tinGoyendaSeries); tinGoyendaSeries.Add(new Book("Jhamela", "Rokib Hasan", 1994)); tinGoyendaSeries.Add(new Book("TusarMeru", "Rokib Hasan", 1993)); BookShelf myShelf = new BookShelf(allBooks); myShelf.GetBookList(); Console.ReadLine(); }
public BookShelfIterator( BookShelf bookShelf ) { m_BookShelf = bookShelf; m_Index = 0; }
public static BookShelf GetFlatBookShelf(BookContainer shelf) { var result = new BookShelf(); if (shelf.Files.Count > 0) { result.Folders.Add(shelf); } result.Title = shelf.Title; foreach (var item in shelf.Folders) { result.Folders.AddRange(GetFlatBookShelf(item).Folders); } shelf.Folders = new List<BookContainer>(); return result; }
public void Should_tell_me_how_many_books_can_fit_into_it() { BookShelf bookShelf = new BookShelf(100); var book = new PhysicalBook("123", "", "", 100, 20); Assert.That(bookShelf.HowManyBooksCanFit(book), Is.EqualTo(5)); }