示例#1
0
        public UserPreferences_Database ParseUserPreferences(string text)
        {
            UserPreferences_Database db           = new UserPreferences_Database();
            IEnumerable <XmlNode>    nodes        = this.ParseToXmlNodes(text);
            List <string>            feedUrls     = new List <string>();
            List <TextRule>          scoringRules = new List <TextRule>();

            foreach (XmlNode node in nodes)
            {
                if (node.Name == this.FeedTag)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (child.Name == this.FeedUrl_Tag)
                        {
                            string url = this.ReadText(child);
                            feedUrls.Add(url);
                        }
                    }
                }
                if (node.Name == this.ScoringRule_Tag)
                {
                    TextRule rule = this.ReadScoringRule(node);
                    scoringRules.Add(rule);
                }
            }
            db.FeedUrls     = feedUrls;
            db.ScoringRules = scoringRules;
            return(db);
        }
示例#2
0
        private void loadPreferences()
        {
            string text = this.fileIo.ReadAllText(this.userPreferences_filePath);

            if (text != null && text != "")
            {
                this.userPreferences_database = UserPreferences_Database.Parse(text);
            }
        }
示例#3
0
        private void CustomizeLayout_RequestImport(string text)
        {
            UserPreferences_Database newDb = this.textConverter.ParseUserPreferences(text);

            this.userPreferences_database.CopyFrom(newDb);
            this.savePreferences();
            this.LayoutStack.RemoveLayout();
            this.LayoutStack.RemoveLayout();
            this.setupRulesScreen();
        }
示例#4
0
        public string ConvertToString(UserPreferences_Database preferencesDatabase)
        {
            StringBuilder result = new StringBuilder();

            foreach (string feedUrl in preferencesDatabase.FeedUrls)
            {
                Dictionary <string, string> properties = new Dictionary <string, string>();
                properties[this.FeedUrl_Tag] = feedUrl;
                string text = this.ConvertToString(properties, this.FeedTag);
                result.Append(text);
            }
            foreach (TextRule rule in preferencesDatabase.ScoringRules)
            {
                string text = this.ConvertToString(rule);
                result.Append(text);
            }
            return(result.ToString());
        }
示例#5
0
 public void CopyFrom(UserPreferences_Database other)
 {
     this.FeedUrls     = other.FeedUrls;
     this.ScoringRules = other.ScoringRules;
 }