Пример #1
0
        async public Task <IResult <List <LastComment> > > GetLastComments()
        {
            IResult <List <LastComment> > Donut = null;
            var Yorumlar = new List <LastComment>();
            var Req      = new RestRequest("/");
            var Res      = this._HttpClient.Get(Req);

            if (Res.StatusCode != System.Net.HttpStatusCode.OK)
            {
                Donut = Result.Fail <List <LastComment> >(Res.StatusDescription);
            }
            else
            {
                var Document = await Res.Content.ConvertHTML();

                var YorumlarHTML = Document.QuerySelectorAll(".most-viewed > .content > li");

                foreach (var YorumHTML in YorumlarHTML)
                {
                    LastComment LastComment = new LastComment();
                    LastComment.ID      = Convert.ToInt32(YorumHTML.QuerySelectorAll("span")[0].Text());
                    LastComment.Episode = YorumHTML.QuerySelectorAll("span")[1].QuerySelector("a").Attributes["href"].Value;

                    var MainText = YorumHTML.QuerySelectorAll("span")[1].QuerySelector("a").Text();
                    var Bol      = Regex.Split(MainText, " için;");

                    LastComment.User = Bol[1].Trim().Replace(" ", "");

                    YorumHTML.QuerySelectorAll("span")[1].QuerySelector("a").Remove();
                    YorumHTML.QuerySelectorAll("span")[1].QuerySelector("br").Remove();

                    LastComment.Comment = YorumHTML.QuerySelectorAll("span")[1].Text().ClearHtmlTags();

                    Yorumlar.Add(LastComment);
                }

                Donut = Result.Success(Yorumlar);
            }

            return(Donut);
        }
Пример #2
0
        public Details ParseComment()
        {
            if (LastComment == null)
            {
                return(new Details());
            }
            MTypescriptParser parser = new MTypescriptParser();

            parser.ParseString = LastComment;
            Details result    = new Details();
            string  header    = null;
            string  paramName = null;

            while (!parser.CurrentIs('\0'))
            {
                parser.GoForwardIf('*');
                if (!parser.GoForwardIf('@'))
                {
                    string g = string.Empty;
                    if (!parser.CurrentIs('\0'))
                    {
                        parser.CreateRestorePoint();
                        parser.InSkipEmpty = true;
                        parser.SkipUntil(LastComment.Substring(parser.index).Contains('@') ? '@' : '\0');
                        parser.InSkipEmpty = false;
                        while (parser.CurrentIs('\0'))
                        {
                            parser.index--;
                        }
                        int oldIndex = parser.restorePoints.Pop();
                        g = LastComment.Substring(oldIndex, parser.index - oldIndex - 1).Replace("*", "");
                    }
                    switch (header)
                    {
                    case "param":
                        result.paramDescription.Add(paramName, g);
                        break;

                    case "returns":
                    case "return":
                        result.returns = g;
                        break;

                    case null:
                        result.summary = g;
                        break;
                    }
                }
                parser.GoForwardIf('*');
                header    = parser.GetWord();
                paramName = null;
                if (parser.GoForwardIf('{'))
                {
                    parser.SkipUntil('}');
                }
                if (header == "param")
                {
                    paramName = parser.GetWord();
                }
            }
            return(result);
        }
Пример #3
0
 public Initiative()
 {
     Last_comment = new LastComment();
 }