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


C# ICatalog.GetListContent方法代码示例

本文整理汇总了C#中ICatalog.GetListContent方法的典型用法代码示例。如果您正苦于以下问题:C# ICatalog.GetListContent方法的具体用法?C# ICatalog.GetListContent怎么用?C# ICatalog.GetListContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICatalog的用法示例。


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

示例1: ExecuteCommand

        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!");
                    }
            }
        }
开发者ID:BobbyBorisov,项目名称:TelerikAcademy,代码行数:60,代码来源:CommandExecutor.cs

示例2: ProcessFindCommand

        private static void ProcessFindCommand(ICatalog contentCatalog,
            ICommand command, StringBuilder output)
        {
            if (command.Parameters.Length != 2)
            {
                throw new ArgumentException("Invalid number of parameters!");
            }

            int numberOfElementsToList = Int32.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);
                }
            }
        }
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:25,代码来源:CommandExecutor.cs

示例3: ExecuteCommand

        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!");
            }
        }
开发者ID:hristian-dimov,项目名称:TelerikAcademy,代码行数:55,代码来源:CommandExecutor.cs

示例4: FindContent

        private void FindContent(ICatalog catalog, ICommand commmand, StringBuilder output, int numberOfElementsToList)
        {
            IEnumerable<IContent> foundContent = catalog.GetListContent(commmand.Parameters[0], numberOfElementsToList);

            if (foundContent.Count() == 0)
            {
                output.AppendLine("No items found");
            }
            else
            {
                foreach (IContent content in foundContent)
                {
                    output.AppendLine(content.TextRepresentation);
                }
            }
        }
开发者ID:Rokata,项目名称:TelerikAcademy,代码行数:16,代码来源:CommandExecutor.cs

示例5: FindContent

        private void FindContent(ICatalog catalog, ICommand command, StringBuilder result)
        {
            if (command.Parameters.Length != 2)
            {
                throw new FormatException("Invalid number of parameters!");
            }

            int numberOfElementsToList = int.Parse(command.Parameters[1]);
            IEnumerable<IContent> foundContent = catalog.GetListContent(command.Parameters[0], numberOfElementsToList);
            if (foundContent.Count() == 0)
            {
                this.UpdateResult(result, "No items found");
            }
            else
            {
                foreach (IContent content in foundContent)
                {
                    this.UpdateResult(result, content.TextRepresentation);
                }
            }
        }
开发者ID:androidejl,项目名称:Telerik,代码行数:21,代码来源:CommandExecutor.cs

示例6: SearchInCatalog

        private static void SearchInCatalog(ICatalog catalog, ICommand command, StringBuilder sb)
        {
            if (command.Parameters.Length != 2)
            {
                throw new Exception("Invalid number of parameters!");
            }

            int numberOfElementsToList = int.Parse(command.Parameters[1]);

            IEnumerable<IContent> foundContent = catalog.GetListContent(command.Parameters[0], numberOfElementsToList);

            if (foundContent.Count() == 0)
            {
                sb.AppendLine("No items found");
            }
            else
            {
                foreach (IContent content in foundContent)
                {
                    sb.AppendLine(content.TextRepresentation);
                }
            }
        }
开发者ID:Dyno1990,项目名称:TelerikAcademy-1,代码行数:23,代码来源:CommandExecutor.cs

示例7: ExecuteCommand

        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!");
                    }
            }
        }
开发者ID:LyuboslavLyubenov,项目名称:High-quality-Code,代码行数:90,代码来源:CommandExecutor.cs

示例8: ExecuteCommand

        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!");
                    }
            }
        }
开发者ID:hrist0stoichev,项目名称:Telerik-Homeworks,代码行数:85,代码来源:CommandExecutor.cs

示例9: Find

        private void Find(ICatalog catalog, ICommand command, StringBuilder consoleOutput)
        {
            if (command.Parameters.Length != 2)
            {
                throw new FormatException("Invalid number of parameters!Mandatory parameters are: Title and count. Probably some are missing.");
            }

            Int32 numberOfElementsToList = Int32.Parse(command.Parameters[1]);
            IEnumerable<IContent> foundContent = catalog.GetListContent(command.Parameters[0], numberOfElementsToList);

            if (foundContent.Count() == 0)
            {
                consoleOutput.AppendLine("No items found");
            }
            else
            {
                foreach (IContent content in foundContent)
                {
                    consoleOutput.AppendLine(content.TextRepresentation);
                }
            }

        }
开发者ID:vaster,项目名称:Telerik.vasko,代码行数:23,代码来源:CommandExecutor.cs

示例10: ExecuteCommand

        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!");
                    }
            }
        }
开发者ID:kalinnikol,项目名称:TelerikAcademy-1,代码行数:69,代码来源:CommandExecutor.cs

示例11: ExecuteCommand

        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!");
                    }
            }
        }
开发者ID:KirilToshev,项目名称:Projects,代码行数:64,代码来源:CommandExecutor.cs


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