示例#1
0
        public ActionResult Index()
        {
            //XMLRadioFeed data = XMlHelperClass.GetXMLData(@"file://*****:*****@"http://harry.radioapi.io/services/nowplaying/utv/fm104/onair");

              XMLRadioFeed data = new XMLRadioFeed();

              return View(data);
        }
示例#2
0
 public ActionResult Index(XMLRadioFeed feed)
 {
     XMLRadioFeed data;
       if (feed.FeedURI != null)
       {
     data = XMlHelperClass.GetXMLData(feed.FeedURI.ToString());
       }
       else
       {
     data = new XMLRadioFeed();
       }
       return View(data);
 }
示例#3
0
        public static XMLRadioFeed GetXMLData(String path)
        {
            XMLRadioFeed feed = new XMLRadioFeed();

              Uri uriResult;
              try
              {
            //adding protocol (default http) to requested uri path if its not present
            path = new UriBuilder(path).ToString();

            bool uriIsValid = Uri.TryCreate(path, UriKind.Absolute, out uriResult);
            if (uriIsValid)
            {
              feed.FeedURI = uriResult;
            }
              }
              catch
              {
            feed.Error = new Exception("Malformed Feed URL String");
            return feed;
              }

              try
              {
            using (XmlReader reader = XmlReader.Create(feed.FeedURI.ToString()))
            {
              XmlSerializer serializer = new XmlSerializer(typeof(onAir));
              feed.onAir = (onAir)serializer.Deserialize(reader);
            }
              }
              catch (Exception e)
              {
            feed.Error = e;
              }

              return feed;
        }