-1

I am trying to make list of object as

 List<FeedItem> List_feeds = new List<FeedItem>();
 FeedItem objFeedItem = new FeedItem();

objFeedItem.feedId = feedNode.SelectSingleNode("id").InnerText;
.
.
.
.
objFeedItem.text  = feedNode.SelectSingleNode("text").InnerXml;
objFeedItem.imgthumb = thumbImage;
objFeedItem.imglarge = largeImage;

 List_feeds.Add(objFeedItem);

Error: "Object reference not set to an instance of an object."

Some One asked for the compleate Code hear it is..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Net;

namespace FSB.Classes
{
    public class FeedItem
    {
        public string feedId{ get; set; }
        public string feed_publishDate{ get; set; }
        public string feed_createDate{ get; set; }
        public string feed_modifieddate{ get; set; }
        public string title{ get; set; }
        public string description{ get; set; }
        public string text{ get; set; }
        public string imgthumb{ get; set; }
        public string imglarge{ get; set; }
        public string addedBy{ get; set; }
        public string edited{ get; set; }
        public string createDate{ get; set; }
        public string updateDat { get; set; }
    }


    public class Feeds
    {

        protected string newsURL;
        protected List<FeedItem> List_feeds;

        public Feeds()
        {
            newsURL = @"http://api.brafton.com/55f3e621-2223-48de-bafc-4f3774e72533/news/";
             List<FeedItem> List_feeds = new List<FeedItem>();
        }


        public void updateAllFeeds()
        {
            getFeedList();


        }

        private void getFeedList()
        {
            try
            {
                XmlDocument objFeedDoc = new XmlDocument();
                var nodeFeedList = getFeedNodes();

                foreach (XmlNode objFeedNode in nodeFeedList)
                {
                    string feedDetailhref = objFeedNode.Attributes["href"].Value;
                    string strFeedDetail = getFeedDetailXml(feedDetailhref);

                    objFeedDoc.LoadXml(strFeedDetail);
                    XmlNode feedNode = objFeedDoc.SelectSingleNode("newsItem");

                    FeedItem objFeedItem = new FeedItem();


                    objFeedItem.feedId =feedNode.SelectSingleNode("id").InnerText;


                    objFeedItem.feedId              = feedNode.SelectSingleNode("id").InnerText;
                    objFeedItem.feed_publishDate    = feedNode.SelectSingleNode("publishDate").InnerText;
                    objFeedItem.feed_createDate     = feedNode.SelectSingleNode("createdDate").InnerText;
                    objFeedItem.feed_modifieddate   = feedNode.SelectSingleNode("lastModifiedDate").InnerText;
                    objFeedItem.title               = feedNode.SelectSingleNode("headline").InnerText;
                    objFeedItem.description         = feedNode.SelectSingleNode("htmlMetaDescription").InnerText;
                    objFeedItem.text                = feedNode.SelectSingleNode("text").InnerXml;


                    string thumbImage = "";
                    string largeImage = "";
                   /*
                    try
                    {

                        string pictureURL = feedNode.SelectSingleNode("photos").Attributes["href"].Value;
                        XmlNode imageNode = getFeedImage(pictureURL);
                        foreach (XmlNode pic in imageNode)
                        {
                            if (pic.SelectSingleNode("type").InnerText.ToLower() == "large")
                            {
                               largeImage = pic.SelectSingleNode("url").InnerText;

                            }
                            if (pic.SelectSingleNode("type").InnerText.ToLower() == "thumb")
                            {
                               thumbImage = pic.SelectSingleNode("url").InnerText;

                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.Message);
                    }
                    */
                    objFeedItem.imgthumb = thumbImage;
                    objFeedItem.imglarge = largeImage;




                    List_feeds.Add(objFeedItem);
                }

            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }


        private XmlNode getFeedImage(string pictureURL)
        {
            try
            {
                XmlDocument picDoc = new XmlDocument();
                var client = new WebClient();
                var content = client.DownloadString(newsURL);

                picDoc.LoadXml(content);
               return picDoc.SelectSingleNode("photos/photo/instances");
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return null;

        }

        /*Extract the newsListItem from the xml Feeds */
         private XmlNodeList getFeedNodes()
         {
             try
             {
                 XmlDocument docFeed = new XmlDocument();
                 string strFeedXml = getFeedXml();
                 docFeed.LoadXml(strFeedXml);
                 return docFeed.SelectNodes("news/newsListItem");
             }
             catch (Exception ex)
             {
                 Console.Write(ex.Message);
             }
             return null;
         }

        /*Get the Xml Feeds From the Live Server*/
        private string getFeedXml()
        {
            try
            {
                var client = new WebClient();
                var content = client.DownloadString(newsURL);
                return content;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return null;
        }

        /*Get the Xml Feeds Details From the Live Server*/
        private string getFeedDetailXml(string newsDetailURL)
        {
            try
            {
                var client = new WebClient();
                var content = client.DownloadString(newsDetailURL);
                return content;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return null;

        }
    }



}

Can the Authorize.Net CIM hosted form design be customized?

When, submit form via getHostedProfilePageRequest, it will be redirect to https://test.authorize.net/profile/addpayment. Can we change css or design for it?

4

3 回答 3

1

Your declaration of

protected List<FeedItem> List_feeds;

is never instantiated.

Change it to

protected List<FeedItem> List_feeds = new List<FeedItem>();

and remove this from the constructor:

List<FeedItem> List_feeds = new List<FeedItem>();

This is because the code in the constructor was simply creating a local variable of the same name as your class level variable, instead of actually instantiating a class level object (as I think you intended)

于 2012-10-31T11:23:59.803 回答
0
List<FeedItem> List_feeds = new List<FeedItem>();

在构造函数中,您正在实例化一个局部变量而不是全局变量。

于 2012-10-31T11:49:22.067 回答
0
var idNode = feedNode.SelectSingleNode("id");
if (idNode != null) {
    objFeedItem.feedId = idNode.InnerText;
    ...
}

var textNode = feedNode.SelectSingleNode("text");
if (textNode != null) {
    objFeedItem.text  = textNode.InnerXml;
    ...
}
于 2012-10-31T11:25:06.960 回答