예제 #1
0
        public static List<ForumPostTitle> ParseForumTitles(String input, int forumIndex)
        {
            JObject json = JObject.Parse(input);

            List<ForumPostTitle> posts = new List<ForumPostTitle>();
            JArray jHeadings = json["Results"] as JArray;
            int i = 0;

            // Multiple headings in current forum
            foreach (var jHeading in jHeadings)
            {
                data.modules[data.curModuleIndex].jPosts[forumIndex].Add(jHeading["Threads"] as JArray);

                foreach (var jPost in data.modules[data.curModuleIndex].jPosts[forumIndex][i])
                {
                    ForumPostTitle newPost = new ForumPostTitle();
                    newPost.Heading = jPost["PostTitle"].ToString();
                    newPost.Timestamp = jPost["PostDate_js"].ToString();
                    newPost.Type = jPost["isSurveyPost"].ToString();
                    newPost.Author = jPost["Poster"]["Name"].ToString();
                    newPost.Votes = 0;
                    newPost.Answers = 0;
                    newPost.Number = 0;                    
                                        
                    posts.Add(newPost);
                }
                i++;
            }

            return posts;
        }
예제 #2
0
        public static List<ForumPostTitle> ParseForumTitles(String input, int forumIndex)
        {
            JObject json = JObject.Parse(input);

            List<ForumPostTitle> posts = new List<ForumPostTitle>();
            JArray jHeadings = json["Results"] as JArray;

            if (jHeadings.Count == 0)
                jHeadings = data.modules[data.curModuleIndex].jPosts["Results"] as JArray; 
            else
                data.modules[data.curModuleIndex].jPosts = json;

            // Multiple headings in current forum
            int i = 0;
            foreach (var jHeading in jHeadings)
            {
                //data.modules[data.curModuleIndex].jPosts[forumIndex].Add(jHeading["Threads"] as JArray);

                int index = 0;
                foreach (var jPost in jHeading["Threads"])
                {
                    ForumPostTitle newPost = new ForumPostTitle();
                    newPost.Heading = jPost["PostTitle"].ToString();
                    newPost.Timestamp = jPost["PostDate_js"].ToString();
                    newPost.Type = jPost["isSurveyPost"].ToString();
                    newPost.Author = jPost["Poster"]["Name"].ToString();
                    newPost.ID = jPost["ID"].ToString();

                    if (jPost["votes"] != null)
                        newPost.Votes = Convert.ToInt32(jPost["votes"].ToString());
                    else
                        newPost.Votes = 0;

                    newPost.threadIndex = index;
                    newPost.Votes = 0;
                    newPost.Answers = 0;
                    newPost.Number = 0;

                    index++;
                    posts.Add(newPost);
                }
                i++;
            }

            return posts;
        }
예제 #3
0
        private static ForumPostTitle convert(JToken jToken)
        {
            ForumPostTitle newPost = new ForumPostTitle();
            newPost.Heading = jToken["PostTitle"].ToString();
            newPost.Timestamp = jToken["PostDate_js"].ToString();
            newPost.Type = jToken["isSurveyPost"].ToString();
            newPost.Author = jToken["Poster"]["Name"].ToString();
            newPost.Votes = 0;
            newPost.Answers = 0;
            newPost.Number = 0;

            return newPost;
        }
예제 #4
0
        public static ForumPostTitle convert(JToken jToken)
        {
            ForumPostTitle newPost = new ForumPostTitle();
            newPost.Heading = jToken["PostTitle"].ToString();
            newPost.Timestamp = jToken["PostDate_js"].ToString();
            newPost.Type = jToken["isSurveyPost"].ToString();
            newPost.Author = jToken["Poster"]["Name"].ToString();
            newPost.ID = jToken["ID"].ToString();
            if (jToken["votes"] != null)
                newPost.Votes = Convert.ToInt32(jToken["votes"].ToString());
            else
                newPost.Votes = 0;

            newPost.Answers = 0;
            newPost.Number = 0;

            return newPost;
        }