public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder sb) { switch (command.Type) { case Commands.AddBook: catalog.Add(new CatalogContent(ContentTypes.Book, command.Parameters)); sb.AppendLine("Book added"); break; case Commands.AddMovie: catalog.Add(new CatalogContent(ContentTypes.Movie, command.Parameters)); sb.AppendLine("Movie added"); break; case Commands.AddSong: catalog.Add(new CatalogContent(ContentTypes.Song, command.Parameters)); sb.AppendLine("Song added"); break; case Commands.AddApplication: catalog.Add(new CatalogContent(ContentTypes.Application, command.Parameters)); sb.AppendLine("Application added"); break; case Commands.Update: UpdateCommand(catalog, command, sb); break; case Commands.Find: FindCommand(command, catalog, sb); break; default: throw new InvalidOperationException("Unknown command!"); } }
public void ExecuteCommand(ICatalog catalog, ICommand cmd, StringBuilder sb) { switch (cmd.Type) { case CommandType.AddBook: catalog.Add(new ContentItem(ContentItemType.Book, cmd.Parameters)); sb.AppendLine("Book added"); break; case CommandType.AddMovie: catalog.Add(new ContentItem(ContentItemType.Movie, cmd.Parameters)); sb.AppendLine("Movie added"); break; case CommandType.AddSong: catalog.Add(new ContentItem(ContentItemType.Song, cmd.Parameters)); sb.AppendLine("Song added"); break; case CommandType.AddApplication: catalog.Add(new ContentItem(ContentItemType.Application, cmd.Parameters)); sb.AppendLine("Application added"); break; case CommandType.Update: if (cmd.Parameters.Length != 2) { throw new FormatException("Format exception"); } var updatedItems = catalog.UpdateContent(cmd.Parameters[0], cmd.Parameters[1]); sb.AppendLine(String.Format("{0} items updated", updatedItems)); break; case CommandType.Find: { if (cmd.Parameters.Length != 2) { Console.WriteLine("Invalid params!"); throw new Exception("Invalid number of parameters!"); } int numberOfElementsToList = int.Parse(cmd.Parameters[1]); IEnumerable<IContent> foundContent = catalog.GetListContent(cmd.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { sb.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { sb.AppendLine(content.TextRepresentation); } } } break; default: { throw new InvalidCastException("Unknown command!"); } } }
private void breeds_RowEdited(DataGridViewRow editRow) { string col0 = "", col1 = "", col2 = ""; if (editRow.Cells[D1].Value != null) { col0 = editRow.Cells[D1].Value.ToString(); } if (editRow.Cells[D2].Value != null) { col1 = editRow.Cells[D2].Value.ToString(); } if (editRow.Cells[D3].Value != null) { col2 = ((Color)(editRow.Cells[D3].Value)).Name; } if (editRow.Cells[_hiddenId].Value == null) { editRow.Cells[_hiddenId].Value = /*Engine.db().getBreeds().*/ _catalog.Add(col0, col1, col2); } else { //Engine.db().getBreeds(). _catalog.Change(Convert.ToInt32(editRow.Cells[_hiddenId].Value), col0, col1, col2); dataGridView1.Refresh(); } }
public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder output) { switch (command.Type) { case CommandType.AddBook: var book = new ContentItem(ContentItemType.Book, command.Parameters); catalog.Add(book); output.AppendLine("Book Added"); break; case CommandType.AddMovie: var movie = new ContentItem(ContentItemType.Movie, command.Parameters); catalog.Add(movie); output.AppendLine("Movie added"); break; case CommandType.AddSong: var song = new ContentItem(ContentItemType.Song, command.Parameters); catalog.Add(song); output.AppendLine("Song added"); break; case CommandType.AddApplication: var application = new ContentItem(ContentItemType.Application, command.Parameters); catalog.Add(application); output.AppendLine("Application added"); break; case CommandType.Update: ProcessUpdateCommand(catalog, command, output); break; case CommandType.Find: ProcessFindCommand(catalog, command, output); break; default: throw new InvalidOperationException("Unknown command!"); } }
public void ExecuteCommand(ICatalog catalog, ICommand commmand, StringBuilder output) { switch (commmand.Type) { case CommandType.AddBook: { catalog.Add(new Content(ContentType.Book, commmand.Parameters)); output.AppendLine("Book added"); break; } case CommandType.AddMovie: { catalog.Add(new Content(ContentType.Movie, commmand.Parameters)); output.AppendLine("Movie added"); break; } case CommandType.AddSong: { catalog.Add(new Content(ContentType.Song, commmand.Parameters)); output.AppendLine("Song added"); break; } case CommandType.AddApplication: { catalog.Add(new Content(ContentType.Application, commmand.Parameters)); output.AppendLine("Application added"); break; } case CommandType.Update: { if (commmand.Parameters.Length != 2) { throw new FormatException("Invalid parameteres count."); } int itemsUpdated = catalog.UpdateContent(commmand.Parameters[0], commmand.Parameters[1]); string updatedInfo = String.Format("{0} items updated", itemsUpdated); output.AppendLine(updatedInfo); break; } case CommandType.Find: { if (commmand.Parameters.Length != 2) { throw new Exception("Invalid number of parameters!"); } int numberOfElementsToList = int.Parse(commmand.Parameters[1]); FindContent(catalog, commmand, output, numberOfElementsToList); break; } default: { throw new ArgumentException("Unknown command type."); } } }
public void ExecuteCommand(ICatalog contentCatalog, ICommand command, StringBuilder output) { switch (command.Type) { case Commands.AddBook: { contentCatalog.Add(new Content(Contents.Book, command.Parameters)); output.AppendLine("Book Added"); } break; case Commands.AddMovie: { contentCatalog.Add(new Content(Contents.Movie, command.Parameters)); output.AppendLine("Movie added"); } break; case Commands.AddSong: { contentCatalog.Add(new Content(Contents.Song, command.Parameters)); output.AppendLine("Song added"); } break; case Commands.AddApplication: { contentCatalog.Add(new Content(Contents.Application, command.Parameters)); output.AppendLine("Application added"); } break; case Commands.Update: { UpdateItem(contentCatalog, command, output); } break; case Commands.Find: { FindItem(contentCatalog, command, output); } break; default: { throw new ArgumentException("Unknown command!"); } } }
public void ExecuteCommand(ICatalog contentCatalog, ICommand command, StringBuilder output) { switch (command.Type) { case CommandType.AddBook: contentCatalog.Add(new ContentItem(ContentType.Book, command.Parameters)); output.AppendLine("Book Added"); break; case CommandType.AddMovie: contentCatalog.Add(new ContentItem(ContentType.Movie, command.Parameters)); output.AppendLine("Movie added"); break; case CommandType.AddSong: contentCatalog.Add(new ContentItem(ContentType.Song, command.Parameters)); output.AppendLine("Song added"); break; case CommandType.AddApplication: contentCatalog.Add(new ContentItem(ContentType.Application, command.Parameters)); output.AppendLine("Application added"); break; case CommandType.Update: if (command.Parameters.Length != 2) { throw new FormatException("Invalid number of Parameters!"); } string message = string.Format("{0} items updated", contentCatalog.UpdateContent(command.Parameters[0], command.Parameters[1])); output.AppendLine(message); break; case CommandType.Find: if (command.Parameters.Length != 2) { throw new FormatException("Invalid number of parameters!"); } int numberOfElementsToList = int.Parse(command.Parameters[1]); IEnumerable<IContent> foundContent = contentCatalog.GetListContent(command.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { output.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { output.AppendLine(content.TextRepresentation); } } break; default: throw new ArgumentException("Unknown command!"); } }
public bool Stock(IActor seller, float price, uint count, IBook book, IDescription description) { // Check if there's enough money to pay for this shipment if (Money < price * count) { return(false); } Money -= price * count; // Ensure the book is listed in the catalog if (!catalog.ContainsKey(book)) { description.Price = price + price * PROFIT_MARGIN; // Change from MSRP to actual price catalog.Add(book, description); } // Update stock count IInvoice invoice = inventory.Stock(book, price, count); // Log the delivery history.LogStock(seller, invoice); return(true); }
private void ExecuteCommandAddApplication(ICommand command, ICatalog catalog, StringBuilder sb) { var application = new Content(ContentType.Application, command.Parameters); catalog.Add(application); sb.AppendLine("Application added"); }
private void ExecuteCommandAddSong(ICommand command, ICatalog catalog, StringBuilder sb) { var song = new Content(ContentType.Song, command.Parameters); catalog.Add(song); sb.AppendLine("Song added"); }
private void ExecuteCommandAddMovie(ICommand command, ICatalog catalog, StringBuilder sb) { var movie = new Content(ContentType.Movie, command.Parameters); catalog.Add(movie); sb.AppendLine("Movie added"); }
private void ExecuteCommandAddBook(ICommand command, ICatalog catalog, StringBuilder sb) { var book = new Content(ContentType.Book, command.Parameters); catalog.Add(book); sb.AppendLine("Book Added"); }
private void AddContent(ContentType type, ICatalog catalog, ICommand command, StringBuilder result) { catalog.Add(new Content(type, command.Parameters)); string updateSring = String.Format("{0} added", type.ToString()); this.UpdateResult(result, updateSring); }
private static void ProcessAddCommand( ICatalog catalog, ContentType contentType, string[] parameters, StringBuilder output) { IContent contentItem = new ContentItem(contentType, parameters); catalog.Add(contentItem); output.AppendFormat("{0} added{1}", contentType, Environment.NewLine); }
public void GetBooksTest() { ICatalog catalog = CatalogGenerator.PrepareData(); IBook book = BookDataGenerator.PrepareData().First(); IDescription description = DescriptionDataGenerator.PrepareData().First(); IBook book2 = BookDataGenerator.PrepareData().Last(); IDescription description2 = DescriptionDataGenerator.PrepareData().Last(); catalog.Add(book, description); catalog.Add(book2, description2); IInventory inventory = InventoryGenerator.PrepareData(); IHistory history = HistoryGenerator.PrepareData(); Store store = new Store(catalog, inventory, history, .0f); Assert.Equal(catalog.Keys, store.GetBooks()); }
public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder stringbuilder) { switch (command.Type) { case CommandType.AddBook: catalog.Add(new Content(ContentType.Book, command.Parameters)); stringbuilder.AppendLine("Book added"); break; case CommandType.AddMovie: catalog.Add(new Content(ContentType.Movie, command.Parameters)); stringbuilder.AppendLine("Movie added"); break; case CommandType.AddSong: catalog.Add(new Content(ContentType.Song, command.Parameters)); stringbuilder.AppendLine("Song added"); break; case CommandType.AddApplication: catalog.Add(new Content(ContentType.Application, command.Parameters)); stringbuilder.AppendLine("Application added"); break; case CommandType.Update: this.UpdateCommand(ref command, ref stringbuilder, ref catalog); break; case CommandType.Find: this.FindCommand(ref command, ref stringbuilder, ref catalog); break; default: { throw new InvalidOperationException("Unknown command!"); } } }
public void ExecuteCommand(ICatalog catalog, ICommand cmd, StringBuilder output) { switch (cmd.Type) { case CommandType.AddBook: catalog.Add(new Content(ContentType.Book, cmd.Parameters)); output.AppendLine("Book added"); break; case CommandType.AddMovie: var item = new Content(ContentType.Movie, cmd.Parameters); catalog.Add(item); output.AppendLine("Movie added"); break; case CommandType.AddSong: catalog.Add(new Content(ContentType.Song, cmd.Parameters)); output.AppendLine("Song added"); break; case CommandType.AddApplication: catalog.Add(new Content(ContentType.Application, cmd.Parameters)); output.AppendLine("Application added"); break; case CommandType.Update: ProcessUpdateCommand(catalog, cmd, output); break; case CommandType.Find: ProcessFindCommand(catalog, cmd, output); break; default: throw new ArgumentException("Unknown command!"); } }
public void GetBookListingTest() { IBook book = BookDataGenerator.PrepareData().First(); IDescription description = DescriptionDataGenerator.PrepareData().First(); ICatalog catalog = CatalogGenerator.PrepareData(); catalog.Add(book, description); IInventory inventory = InventoryGenerator.PrepareData(); IHistory history = HistoryGenerator.PrepareData(); Store store = new Store(catalog, inventory, history, .0f); Assert.Equal(description, store.GetBookListing(book)); }
private void Add(ContentType contentType, ICommand command, ICatalog contentCatalog, StringBuilder output) { IContent currentBook = new Content(contentType, command.Parameters); contentCatalog.Add(currentBook); output.AppendLine(contentType + " added"); }
public void ExecuteCommand(ICatalog contCat, ICommand command, StringBuilder output) { switch (command.Type) { case ContentCommand.AddBook: contCat.Add(new Content(ContentType.Book, command.Parameters)); output.AppendLine("Book Added"); break; case ContentCommand.AddMovie: contCat.Add(new Content(ContentType.Movie, command.Parameters)); output.AppendLine("Movie added"); break; case ContentCommand.AddSong: contCat.Add(new Content(ContentType.Song, command.Parameters)); output.AppendLine("Song added"); break; case ContentCommand.AddApplication: contCat.Add(new Content(ContentType.Application, command.Parameters)); output.AppendLine("Application added"); break; case ContentCommand.Update: ProcessUpdateCommand(command, contCat, output); break; case ContentCommand.Find: ProcessFindCommand(command, contCat, output); break; default: throw new ArgumentException("Invalid command!"); } }
private static void InsertInCatalog(ICatalog catalog, ICommand command, StringBuilder sb, Content content, string userOutput) { catalog.Add(new CatalogEntry(content, command.Parameters)); sb.AppendLine(userOutput); }
private static void AddBookCommand(ICatalog catalog, ICommand command, StringBuilder output) { catalog.Add(new Content(ContentTypes.Book, command.Parameters)); output.AppendLine("Book added"); }
private static void ExecuteAddApplicationCommand(ICatalog catalog, ICommand command, StringBuilder output) { catalog.Add(new ContentItem(ItemType.Application, command.Parameters)); output.AppendLine("Application added"); }
private static void AddSongCommand(ICatalog catalog, ICommand command, StringBuilder output) { catalog.Add(new Content(ContentTypes.Song, command.Parameters)); output.AppendLine("Song added"); }
public void ExecuteCommand(ICatalog contentCatalog, ICommand command, StringBuilder result) { switch (command.Type) { case CommandType.AddBook: { contentCatalog.Add(new Content(ContentType.Book, command.Parameters)); result.AppendLine("Book added"); } break; case CommandType.AddMovie: { contentCatalog.Add(new Content(ContentType.Movie, command.Parameters)); result.AppendLine("Movie added"); } break; case CommandType.AddSong: { contentCatalog.Add(new Content(ContentType.Song, command.Parameters)); result.AppendLine("Song added"); } break; case CommandType.AddApplication: { contentCatalog.Add(new Content(ContentType.Application, command.Parameters)); result.AppendLine("Application added"); } break; case CommandType.Update: { if (command.Parameters.Length != 2) { throw new ArgumentException("Update can only be used with 2 parameters!"); } result.AppendLine(string.Format("{0} items updated", contentCatalog.UpdateContent(command.Parameters[0], command.Parameters[1]))); } break; case CommandType.Find: { if (command.Parameters.Length != 2) { throw new ArgumentException("Find can only be used with 2 parameters!"); } int numberOfElementsToList = int.Parse(command.Parameters[1]); IEnumerable<IContent> foundContent = contentCatalog.GetListContent(command.Parameters[0], numberOfElementsToList); this.StringifyFoundContent(foundContent, result); } break; default: { throw new InvalidCastException("Unknown command!"); } } }
public void ExecuteCommand(ICatalog contCat, ICommand command, StringBuilder sb) { switch (command.Type) { case CommandType.AddBook: contCat.Add(new Content(ContentType.Book, command.Parameters)); sb.AppendLine("Book added"); break; case CommandType.AddMovie: contCat.Add(new Content(ContentType.Movie, command.Parameters)); sb.AppendLine("Movie added"); break; case CommandType.AddSong: contCat.Add(new Content(ContentType.Song, command.Parameters)); sb.AppendLine("Song added"); break; case CommandType.AddApplication: contCat.Add(new Content(ContentType.Application, command.Parameters)); sb.AppendLine("Application added"); break; case CommandType.Update: if (command.Parameters.Length != 2) { throw new FormatException("Invalid number of parameters!"); } sb.AppendLine(string.Format("{0} items updated", contCat.UpdateContent(command.Parameters[0], command.Parameters[1]))); break; case CommandType.Find: if (command.Parameters.Length != 2) { throw new Exception("Invalid number of parameters!"); } int numberOfElementsToList = int.Parse(command.Parameters[1]); IEnumerable <IContent> foundContent = contCat.GetListContent(command.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { sb.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { sb.AppendLine(content.TextRepresentation); } } break; default: throw new InvalidCastException("Unknown command!"); } }
public void ExecuteCommand(ICatalog catalog, ICommandParser commandParser, StringBuilder stringBuilder) { switch (commandParser.Type) { case Command.AddBook: { catalog.Add(new Content(CatalogType.Book, commandParser.Parameters)); stringBuilder.AppendLine("Book added"); } break; case Command.AddMovie: { catalog.Add(new Content(CatalogType.Movie, commandParser.Parameters)); stringBuilder.AppendLine("Movie added"); } break; case Command.AddSong: { catalog.Add(new Content(CatalogType.Song, commandParser.Parameters)); stringBuilder.AppendLine("Song added"); } break; case Command.AddApplication: { catalog.Add(new Content(CatalogType.Application, commandParser.Parameters)); stringBuilder.AppendLine("Application added"); } break; case Command.Update: { if (commandParser.Parameters.Length != 2) { throw new FormatException("Invalid Parameters!"); } stringBuilder.AppendLine( string.Format( "{0} items updated", catalog.UpdateContent(commandParser.Parameters[0], commandParser.Parameters[1]))); } break; case Command.Find: { if (commandParser.Parameters.Length != 2) { Console.WriteLine("Invalid params!"); throw new Exception("Invalid number of parameters!"); } var numberOfElementsToList = int.Parse(commandParser.Parameters[1]); var foundContent = catalog.GetListContent(commandParser.Parameters[0], numberOfElementsToList); var enumerable = foundContent as IContent[] ?? foundContent.ToArray(); if (!enumerable.Any()) { stringBuilder.AppendLine("No items found"); } else { foreach (var content in enumerable) { stringBuilder.AppendLine(content.ToString()); } } } break; default: { throw new InvalidCastException("Unknown command!"); } } }
private void AddAplication(ICatalog catalog, ICommand command, StringBuilder consoleOutput) { catalog.Add(new Content(CatalogItem.Application, command.Parameters)); consoleOutput.AppendLine("Application added"); }
private void AddSong(ICatalog catalog, ICommand command, StringBuilder consoleOutput) { catalog.Add(new Content(CatalogItem.Song, command.Parameters)); consoleOutput.AppendLine("Song added"); }
public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder output) { switch (command.Type) { case CommandType.AddBook: catalog.Add(new Content(ContentType.Book, command.Parameters)); output.AppendLine("Book added"); break; case CommandType.AddMovie: catalog.Add(new Content(ContentType.Movie, command.Parameters)); output.AppendLine("Movie added"); break; case CommandType.AddSong: catalog.Add(new Content(ContentType.Song, command.Parameters)); output.AppendLine("Song added"); break; case CommandType.AddApplication: catalog.Add(new Content(ContentType.Application, command.Parameters)); output.AppendLine("Application added"); break; case CommandType.Update: if (command.Parameters.Length == 2) { } else { throw new FormatException("The given paremeters must be exactly 2!"); } output.AppendLine(String.Format("{0} items updated", catalog.UpdateContent(command.Parameters[0].Trim(), command.Parameters[1].Trim()))); break; case CommandType.Find: if (command.Parameters.Length != 2) { throw new ArgumentException("Invalid number of parameters!"); } int numberOfElementsToList = int.Parse(command.Parameters[1]); IEnumerable <IContent> foundContent = catalog.GetListContent(command.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { output.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { output.AppendLine(content.TextRepresentation); } } break; default: throw new ArgumentException("The given command is unknown to the CommandExecutor"); } }
public void ExecuteCommand(ICatalog contCat, ICommand c, StringBuilder sb) { switch (c.Type) { case CommandTypes.AddBook: { contCat.Add(new CatalogItem(ContentType.Kniga, c.Parameters) );sb.AppendLine("Books Added"); }break; case CommandTypes.AddMovie: { contCat.Add(new CatalogItem(ContentType.Film, c.Parameters)); sb.AppendLine("Movie added"); } break; case CommandTypes.AddSong: { contCat.Add(new CatalogItem(ContentType.Muzika, c.Parameters)); sb.Append("Song added"); } break; case CommandTypes.AddApplication: { contCat.Add(new CatalogItem(ContentType.Prilozenie, c.Parameters)); sb.AppendLine("Application added"); } break; case CommandTypes.Update: { if (c.Parameters.Length == 2) { } else { throw new FormatException("невалидни параметри!"); } sb.AppendLine(String.Format("{0} items updated", contCat.UpdateContent(c.Parameters[0], c.Parameters[1]) - 1)); } break; case CommandTypes.Find: { if (c.Parameters.Length != 2) { Console.WriteLine("Invalid params!"); throw new Exception("Invalid number of parameters!"); } Int32 numberOfElementsToList = Int32.Parse(c.Parameters[1]); IEnumerable<IContent> foundContent = contCat.GetListContent(c.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { sb.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { sb.AppendLine(content.TextRepresentation); } } } break; default: { throw new InvalidCastException("Unknown command!"); } } }
public void ExecuteCommand(ICatalog contCat, ICommand c, StringBuilder sb) { switch (c.Type) { case CommandType.AddBook: { contCat.Add(new Content(ContentType.Book, c.Parameters) ); sb.AppendLine("Books Added"); } break; case CommandType.AddMovie: { contCat.Add(new Content(ContentType.Movie, c.Parameters)); sb.AppendLine("Movie added"); } break; case CommandType.AddSong: { contCat.Add(new Content(ContentType.Song, c.Parameters)); sb.Append("Song added"); } break; case CommandType.AddApplication: { contCat.Add(new Content(ContentType.Application, c.Parameters)); sb.AppendLine("Application added"); } break; case CommandType.Update: { if (c.Parameters.Length == 2) { } else { throw new FormatException("невалидни параметри!"); } sb.AppendLine(String.Format("{0} items updated", contCat.UpdateContent(c.Parameters[0], c.Parameters[1]) - 1)); } break; case CommandType.Find: { if (c.Parameters.Length != 2) { Console.WriteLine("Invalid params!"); throw new Exception("Invalid number of parameters!"); } Int32 numberOfElementsToList = Int32.Parse(c.Parameters[1]); IEnumerable <IContent> foundContent = contCat.GetListContent(c.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { sb.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { sb.AppendLine(content.TextRepresentation); } } } break; default: { throw new InvalidCastException("Unknown command!"); } } }
public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder commandResult) { switch (command.Type) { case CommandType.AddBook: catalog.Add(new Content(ContentType.Book, command.Parameters)); commandResult.AppendLine("Book added"); break; case CommandType.AddMovie: catalog.Add(new Content(ContentType.Movie, command.Parameters)); commandResult.AppendLine("Movie added"); break; case CommandType.AddSong: catalog.Add(new Content(ContentType.Song, command.Parameters)); commandResult.AppendLine("Song added"); break; case CommandType.AddApplication: catalog.Add(new Content(ContentType.Application, command.Parameters)); commandResult.AppendLine("Application added"); break; case CommandType.Update: if (command.Parameters.Length != 2) { throw new ArgumentException("Update command must have exactly two URLs"); } int itemsUpdated = catalog.UpdateContent(command.Parameters[0], command.Parameters[1]); commandResult.AppendLine(String.Format("{0} items updated", itemsUpdated)); break; case CommandType.Find: { if (command.Parameters.Length != 2) { throw new ArgumentException("Find command must have exactly two parameters"); } Int32 numberOfElementsToList = Int32.Parse(command.Parameters[1]); IEnumerable<IContent> foundContent = catalog.GetListContent(command.Parameters[0], numberOfElementsToList); if (foundContent.Count() == 0) { commandResult.AppendLine("No items found"); } else { foreach (IContent content in foundContent) { commandResult.AppendLine(content.TextRepresentation); } } } break; default: { throw new InvalidCastException("Unknown command!"); } } }