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


C# ICatalog.UpdateContent方法代码示例

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


在下文中一共展示了ICatalog.UpdateContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ExecuteCommand

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

示例3: Update

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

            consoleOutput.AppendLine(String.Format("{0} items updated", catalog.UpdateContent(command.Parameters[0], command.Parameters[1])));
        }
开发者ID:vaster,项目名称:Telerik.vasko,代码行数:9,代码来源:CommandExecutor.cs

示例4: UpdateCommand

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

            int updatedItems = catalog.UpdateContent(command.Parameters[0], command.Parameters[1]);
            sb.AppendLine(string.Format("{0} items updated", updatedItems));
        }
开发者ID:niki-funky,项目名称:Telerik_Academy,代码行数:10,代码来源:CommandExecutor.cs

示例5: ProcessUpdateCommand

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

            output.AppendLine(String.Format("{0} items updated",
                catalog.UpdateContent(cmd.Parameters[0], cmd.Parameters[1])));
        }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:10,代码来源:CommandExecutor.cs

示例6: 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

示例7: UpdateItem

        private void UpdateItem(ICatalog contentCatalog, ICommand command, StringBuilder output)
        {
            if (command.Parameters.Length != 2)
            {
                throw new ArgumentException("Ivalid number of paramethers!");
            }

            output.AppendLine(string.Format(
                "{0} items updated",
                contentCatalog.UpdateContent(command.Parameters[0], command.Parameters[1])));
        }
开发者ID:HansS,项目名称:TelerikAcademy-homework,代码行数:11,代码来源:CommandExecutor.cs

示例8: ProcessUpdateCommand

 private static void ProcessUpdateCommand(ICatalog catalog, ICommand command, StringBuilder output)
 {
     if (command.Parameters.Length == 2)
     {
         int itemsUpdated = catalog.UpdateContent(command.Parameters[0], command.Parameters[1]);
         output.AppendFormat("{0} items updated{1}", itemsUpdated, Environment.NewLine);
     }
     else
     {
         throw new ArgumentException("Invalid number of parameters for 'Update' command!");
     }
 }
开发者ID:smihaylovit,项目名称:TelerikAcademy,代码行数:12,代码来源:CommandExecutor.cs

示例9: ExecuteCommandUpdate

        private void ExecuteCommandUpdate(ICommand command, ICatalog catalog, StringBuilder sb)
        {
            if (command.Parameters.Length != 2)
            {
                throw new FormatException("Command parameters length must be == 2!");
            }

            int numberOfUpdatedItems = catalog.UpdateContent(command.Parameters[0], command.Parameters[1]);
            string updatedOutputMessage = string.Format("{0} items updated", numberOfUpdatedItems);

            sb.AppendLine(updatedOutputMessage);
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:12,代码来源:CommandExecutor.cs

示例10: UpdateCommand

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

            int itemsUpdated =
                contentCatalog.UpdateContent(command.Parameters[0], command.Parameters[1]);
            string updateCommandResutl = String.Format("{0} items updated", itemsUpdated);
            output.AppendLine(updateCommandResutl);
        }
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:13,代码来源:CommandExecutor.cs

示例11: ExecuteCommand

 public void ExecuteCommand(ICatalog catalog, ICommand command, StringBuilder sb)
 {
     switch (command.Type)
     {
         case Command.AddBook:
             {
                 InsertInCatalog(catalog, command, sb, Content.Book, "Book Added");
             }
             break;
         case Command.AddMovie:
             {
                 InsertInCatalog(catalog, command, sb, Content.Movie, "Movie added");
             }
             break;
         case Command.AddSong:
             {
                 InsertInCatalog(catalog, command, sb, Content.Song, "Song added");
             }
             break;
         case Command.AddApplication:
             {
                 InsertInCatalog(catalog, command, sb, Content.Application, "Application added");
             }
             break;
         case Command.Update:
             {
                 if (command.Parameters.Length != 2)
                 {
                     throw new FormatException("Must provide two parameters.");
                 }
                 int updatedEntries = catalog.UpdateContent(command.Parameters[0], command.Parameters[1]);
                 sb.AppendLine(String.Format("{0} items updated", updatedEntries));
             }
             break;
         case Command.Find:
             {
                 SearchInCatalog(catalog, command, sb);
             }
             break;
         default:
             {
                 throw new InvalidCastException("Incorrect command!");
             }
     }
 }
开发者ID:Dyno1990,项目名称:TelerikAcademy-1,代码行数:45,代码来源:CommandExecutor.cs

示例12: 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

示例13: 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

示例14: 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

示例15: UpdateContent

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

            string updateString = String.Format("{0} items updated", catalog.UpdateContent(command.Parameters[0], command.Parameters[1]));
            this.UpdateResult(result, updateString);
        }
开发者ID:androidejl,项目名称:Telerik,代码行数:10,代码来源:CommandExecutor.cs


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