Exemple #1
0
        public static void Persist(List <Feed> feeds)
        {
            // save feed info
            try
            {
                //Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                Configuration configuration = OpenConfig();
                FeedsSection  section       = (FeedsSection)configuration.GetSection(FEED_SETTINGS_SECTION_NAME);
                if (section == null)
                {
                    section          = new FeedsSection();
                    section.LockItem = false;
                    section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
                    section.SectionInformation.ForceSave          = true;
                    configuration.Sections.Add(FEED_SETTINGS_SECTION_NAME, section);
                }
                section.Feeds.Clear();

                foreach (Feed feed in feeds)
                {
                    FeedElement fe = new FeedElement();
                    fe.Name         = feed.ActualName;
                    fe.Url          = feed.Url;
                    fe.PollInterval = feed.PollInterval;
                    fe.CustomName   = feed.CustomName;
                    fe.Username     = feed.Username;
                    fe.Password     = feed.Password;
                    section.Feeds.Add(fe);
                }

                configuration.Save();
            }
            catch
            {
            }
        }
Exemple #2
0
        public static List <Feed> Read()
        {
            // read feed info
            List <Feed> feeds = new List <Feed>();

            try
            {
                //Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                Configuration configuration = OpenConfig();
                FeedsSection  section       = (FeedsSection)configuration.GetSection(FEED_SETTINGS_SECTION_NAME);
                if (section != null)
                {
                    foreach (FeedElement fe in section.Feeds)
                    {
                        Feed feed = Feed.Create(fe.Url, fe.PollInterval, fe.CustomName, fe.Username, fe.Password);
                        feeds.Add(feed);
                    }
                }
            }
            catch
            {
            }
            return(feeds);
        }
        public static void Persist(List<Feed> feeds)
        {
            // save feed info
            try
            {
                //Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                Configuration configuration = OpenConfig();
                FeedsSection section = (FeedsSection) configuration.GetSection(FEED_SETTINGS_SECTION_NAME);
                if (section == null)
                {
                    section = new FeedsSection();
                    section.LockItem = false;
                    section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
                    section.SectionInformation.ForceSave = true;
                    configuration.Sections.Add(FEED_SETTINGS_SECTION_NAME, section);
                }
                section.Feeds.Clear();

                foreach (Feed feed in feeds)
                {
                    FeedElement fe = new FeedElement();
                    fe.Name = feed.ActualName;
                    fe.Url = feed.Url;
                    fe.PollInterval = feed.PollInterval;
                    fe.CustomName = feed.CustomName;
                    fe.Username = feed.Username;
                    fe.Password = feed.Password;
                    section.Feeds.Add(fe);
                }

                configuration.Save();
            }
            catch
            {
            }
        }