示例#1
0
 public void AddCategory(FeedCategory parentCategory, string categoryName)
 {
     if (parentCategory.subCategories == null)
     {
         parentCategory.subCategories = new List <FeedCategory>();
     }
     parentCategory.subCategories.Add(new FeedCategory()
     {
         name = categoryName, parent = parentCategory
     });
 }
示例#2
0
 public void AddCategory(string categoryName)
 {
     if (_feedTree == null)
     {
         _feedTree = new FeedCategory()
         {
             name = "root"
         }
     }
     ;
     AddCategory(_feedTree, categoryName);
 }
 void resetParent(FeedCategory category)
 {
     foreach (var c in category.subCategories)
     {
         c.parent = category;
         resetParent(c);
     }
     foreach (var n in category.subNodes)
     {
         n.parent = category;
     }
 }
示例#4
0
 public FeedNode AddFeed(string FeedName, string FeedUrl)
 {
     if (_feedTree == null)
     {
         _feedTree = new FeedCategory()
         {
             name = "root"
         }
     }
     ;
     return(AddFeed(_feedTree, FeedName, FeedUrl));
 }
示例#5
0
        public FeedNode AddFeed(FeedCategory parentCategory, string FeedName, string FeedUrl)
        {
            if (parentCategory.subNodes == null)
            {
                parentCategory.subNodes = new List <FeedNode>();
            }
            FeedNode i = new FeedNode()
            {
                name = FeedName, url = FeedUrl, parent = parentCategory
            };

            parentCategory.subNodes.Add(i);
            return(i);
        }
示例#6
0
 void resetParent(FeedCategory category)
 {
     if (category.subCategories != null)
     {
         foreach (var c in category.subCategories)
         {
             c.parent = category;
             resetParent(c);
         }
     }
     if (category.subNodes != null)
     {
         foreach (var n in category.subNodes)
         {
             n.parent = category;
         }
     }
 }
示例#7
0
 public bool ReadFromFile(string filePath)
 {
     if (File.Exists(filePath))
     {
         using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
         {
             using (var reader = new StreamReader(fs))
             {
                 var feeds = JsonUtil.Json2Obj(reader.ReadToEnd());
                 if (feeds?.subCategories?.Count > 0 || feeds?.subNodes?.Count > 0)
                 {
                     _feedTree = feeds;
                     resetParent(_feedTree);
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public bool ReadFromFile(string filePath)
 {
     if (File.Exists(filePath))
     {
         using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
         {
             using (var reader = new StreamReader(fs))
             {
                 var feeds = JsonUtil.Json2Obj(reader.ReadToEnd());
                 if (feeds?.subCategories.Count > 0 || feeds?.subNodes.Count > 0)
                 {
                     _feedTree = feeds;
                     resetParent(_feedTree);
                     return true;
                 }
             }
         }
     }
     return false;
 }
示例#9
0
 public void RemoveCategory(FeedCategory category)
 {
     category?.parent?.subCategories?.Remove(category);
 }
示例#10
0
 public void RemoveCategory(FeedCategory category)
 {
     category?.parent?.subCategories?.Remove(category);
 }
示例#11
0
 public FeedNode AddFeed(FeedCategory parentCategory, string FeedName, string FeedUrl)
 {
     if (parentCategory.subNodes == null)
         parentCategory.subNodes = new List<FeedNode>();
     FeedNode i = new FeedNode() { name = FeedName, url = FeedUrl, parent = parentCategory };
     parentCategory.subNodes.Add(i);
     return i;
 }
示例#12
0
 public void AddFeed(string FeedName, string FeedUrl)
 {
     if (_feedTree == null)
         _feedTree = new FeedCategory() { name = "root" };
     AddFeed(_feedTree, FeedName, FeedUrl);
 }
示例#13
0
 public void AddCategory(FeedCategory parentCategory, string categoryName)
 {
     if (parentCategory.subCategories == null)
         parentCategory.subCategories = new List<FeedCategory>();
     parentCategory.subCategories.Add(new FeedCategory() { name = categoryName, parent = parentCategory });
 }
示例#14
0
 public void AddCategory(string categoryName)
 {
     if (_feedTree == null)
         _feedTree = new FeedCategory() { name = "root" };
     AddCategory(_feedTree, categoryName);
 }
示例#15
0
文件: JsonUtil.cs 项目: sgww/cozy
 public static string Obj2Json(FeedCategory root)
 {
     return(JsonConvert.SerializeObject(root, Formatting.Indented));
 }
示例#16
0
文件: JsonUtil.cs 项目: xxy1991/cozy
 public static string Obj2Json(FeedCategory root)
 {
     return JsonConvert.SerializeObject(root, Formatting.Indented);
 }
示例#17
0
 public void AddFeed(FeedCategory parentCategory, string FeedName, string FeedUrl)
 {
     if (parentCategory.subNodes == null)
         parentCategory.subNodes = new List<FeedNode>();
     parentCategory.subNodes.Add(new FeedNode() { name = FeedName, url = FeedUrl, parent = parentCategory });
 }
示例#18
0
 public FeedNode AddFeed(string FeedName, string FeedUrl)
 {
     if (_feedTree == null)
         _feedTree = new FeedCategory() { name = "root" };
     return AddFeed(_feedTree, FeedName, FeedUrl);
 }