/// <summary> /// Parses a "tag" command from somewhere within an input string, /// constructing a <see cref="TagCommandParameters"/> object as a result to represent the parsed command. /// </summary> /// <param name="Input">The input string that contains the "tag" command</param> /// <param name="StartsAt">The position at which the "tag" command begins, which should be the offset at which the command prefix begins</param> /// <param name="HostCommentID">ID of the Imgur Comment the command is within</param> /// <param name="OnItemID">The ID of the Imgur Gallery Item that the Comment containing the command is for</param> /// <param name="ItemAlbum">Whether or not <paramref name="OnItemID"/> is an Album rather than an Image</param> /// <param name="Result">The parsed result, if the parse was successful</param> /// <returns>true if the parse suceeded and so <paramref name="Result"/> was set, otherwise false</returns> public bool ParseTagCommand(string Input, int StartsAt, int HostCommentID, string OnItemID, bool ItemAlbum, out TagCommandParameters Result) { Result = null; Match ParsedTagCommand = Pattern_Tag.Match(Input, StartsAt); if (!ParsedTagCommand.Success) { return(false); } Result = new TagCommandParameters( HostCommentID, OnItemID, ItemAlbum, ParsedTagCommand.Groups[1].Value, ParseRatingSpecifier( ParsedTagCommand.Groups[2].Success ? ParsedTagCommand.Groups[2].Value : null ), ( from ParsedCategory in ParsedTagCommand.Groups[3].Captures where !string.IsNullOrEmpty(ParsedCategory.Value) select ParsedCategory.Value ).ToList() ); return(true); }
Task Imgur.ImgurCommandHandler.ProcessTagCommand(Imgur.TagCommandParameters Parsed) { Console.WriteLine("Taglist - {0}", Parsed.TaglistName); Console.WriteLine("Rating - {0}", Parsed.Rating); Console.Write("Categories -"); foreach (string Category in Parsed.Categories) { Console.Write(" {0}", Category); } Console.WriteLine(); Console.WriteLine(); return(Task.CompletedTask); }