Esempio n. 1
0
        public static Feed AddNewFeed(String content, String name, String url, String updateInterval, String category)
        {
            Feed feed = new Feed();

            String path = (Environment.CurrentDirectory + $"\\podcasts\\{name}"); // Path to a folder containing all XML files in the project directory

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }

            var freshGuid = Guid.NewGuid();

            path = Path.Combine(Environment.CurrentDirectory, $@"podcasts\\{name}", freshGuid + ".xml");

            File.AppendAllText(path, content);

            feed.Filepath       = ($@"{path}"); // append the PATH to the XML on the feed object. This is useful for deleting items directly from the XML file.
            feed.Name           = name;
            feed.URL            = url;
            feed.UpdateInterval = Int32.Parse(updateInterval);
            feed.LastUpdated    = DateTime.Now;
            feed.Category       = category;
            feed.Id             = freshGuid;
            FeedList.Add(feed);

            //THIS IGNORES ADDING THE CONTENT PROPERTY TO OUR SETTINGS FILES, AS IT IS

            var attributes = new XmlAttributes {
                XmlIgnore = true
            };

            var overrides = new XmlAttributeOverrides();

            overrides.Add(typeof(Feed), "Items", attributes);

            feed.SaveSettingsXML();

            return(feed);
        }