Example #1
0
        public static List<Comment> GetComments(Story story)
        {
            List<Comment> comments = new List<Comment>();
            string url = string.Format(Globals.Base + "stories/{0}/comments?count={1}&appkey={2}", story.Id, Globals.Count, Globals.AppKey);
            XmlTextReader reader = Parser.CreateWebRequest(url);
            Comment newComment = new Comment();

            while (reader.Read())
            {
                List<string> attribs = new List<string>();
                if (reader.HasAttributes)
                {
                    for (int i = 0; i < reader.AttributeCount; i++)
                    {
                        attribs.Add(reader.GetAttribute(i).ToString());
                    }
                }

                if (reader.LocalName == "comment")
                {
                    newComment.Text = reader.ReadString();
                    newComment.Date = attribs[0];
                    newComment.Id = attribs[1];
                    newComment.Up = attribs[3];
                    newComment.Down = attribs[4];
                    newComment.Replies = attribs[5];
                    newComment.User = attribs[6];

                    comments.Add(newComment);
                    newComment = new Comment();
                }
            }
            return comments;
        }
Example #2
0
        public static void populateStoryCollection(StoryCollection alStories,
                                                   string diggWebServiceUrl)
        {
            Story newStory = new Story();
            XmlTextReader reader = Parser.CreateWebRequest(diggWebServiceUrl);

            while (reader.Read())
            {
                if (reader.Name == "story")
                {
            //                    for (int i = 0; i < reader.AttributeCount; i++)
                    //{
            //                        switch (i)
              //                      {
                    if (reader.GetAttribute("id") != null)
                    {
                        newStory.Id = reader.GetAttribute("id").ToString();
                        newStory.Link = reader.GetAttribute("href").ToString();
                        newStory.Diggs = reader.GetAttribute("diggs").ToString();
                        newStory.Comments = reader.GetAttribute("comments").ToString();
                        newStory.Status = reader.GetAttribute("status").ToString();
                    }
                            /*case 0: newStory.Id = reader.GetAttribute(i).ToString(); break;
                            case 5: newStory.Link = reader.GetAttribute(i).ToString();
                                newStory.Status = reader.GetAttribute(i).ToString(); break;
                            case 2: newStory.SubmitDate = reader.GetAttribute(i).ToString(); break;
                            case 3: newStory.Diggs = reader.GetAttribute(i).ToString(); break;
                            case 4: //newStory.Comments = new CommentsCollection(newStory); break;
                                newStory.Comments = reader.GetAttribute(i).ToString(); break;
                            case 7: newStory.CommentsUrl = reader.GetAttribute(i).ToString(); break;
                            case 6: newStory.PromoteDate = reader.GetAttribute(i).ToString(); break;
                             */
                        //}
                    //}
                }

                if (reader.Name == "title")
                {
                    newStory.Title = reader.ReadString();
                }

                if (reader.Name == "description")
                {
                    newStory.Description = reader.ReadString();
                }

                if (reader.Name == "user")
                {
                    for (int i = 0; i < reader.AttributeCount; i++)
                    {
                        switch (i)
                        {
                            case 0: newStory.Submitter = reader.GetAttribute(i).ToString(); break;
                            case 1: newStory.SubmitterIcon = reader.GetAttribute(i).ToString(); break;
                            case 3: newStory.SubmitterProfileViews = reader.GetAttribute(i).ToString(); break;
                        }
                    }
                }

                if (reader.Name == "topic")
                {
                    newStory.Topic = reader.GetAttribute(0).ToString();
                }

                if (reader.Name == "container")
                {
                    newStory.Container = reader.GetAttribute(0);
                    alStories.Add(newStory);
                    newStory = new Story();
                }
            }
        }
Example #3
0
 public bool Contains(Story c)
 {
     return cContains(c);
 }
Example #4
0
 public void Add(Story c)
 {
     alStory.Add(c);
 }
Example #5
0
 private bool cContains(Story c)
 {
     return (alStory.Contains(c)) ? true : false;
 }
Example #6
0
 public CommentsCollection(Story story)
 {
     alComments = Parser.GetComments(story);
 }
Example #7
0
 /// <summary>
 /// Builds Story Object Based on Story ID
 /// </summary>
 /// <param name="storyId">Story ID</param>
 /// <returns>Story Object</returns>
 public Story GetStoryByID(string storyId)
 {
     Story iStory = new Story();
     StoryCollection articles = new StoryCollection(ArticleType.byId,
                                                    storyId);
     foreach (Story aStory in articles)
     {
         iStory = aStory;
     }
     return iStory;
 }