Пример #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);
 }
Пример #3
0
 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);
 }
Пример #8
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;
 }
Пример #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
 public static string Obj2Json(FeedCategory root)
 {
     return(JsonConvert.SerializeObject(root, Formatting.Indented));
 }
Пример #16
0
 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);
 }