2015-07-29 19:30:28 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
2015-07-19 23:05:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Jackett.Models
|
|
|
|
|
{
|
|
|
|
|
public class TorznabCategory
|
|
|
|
|
{
|
2015-07-28 23:10:04 +00:00
|
|
|
|
public int ID { get; set; }
|
2015-07-19 23:05:30 +00:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<TorznabCategory> SubCategories { get; private set; }
|
|
|
|
|
|
|
|
|
|
public TorznabCategory()
|
|
|
|
|
{
|
|
|
|
|
SubCategories = new List<TorznabCategory>();
|
|
|
|
|
}
|
2015-07-29 19:30:28 +00:00
|
|
|
|
|
2015-08-12 05:41:12 +00:00
|
|
|
|
public TorznabCategory(int id, string name)
|
|
|
|
|
{
|
|
|
|
|
ID = id;
|
|
|
|
|
Name = name;
|
|
|
|
|
SubCategories = new List<TorznabCategory>();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
public bool Contains(TorznabCategory cat)
|
|
|
|
|
{
|
|
|
|
|
if (this == cat)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (SubCategories.Contains(cat))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
2017-01-16 16:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 19:30:28 +00:00
|
|
|
|
public JToken ToJson()
|
|
|
|
|
{
|
|
|
|
|
var t = new JObject();
|
|
|
|
|
t["ID"] = ID;
|
|
|
|
|
t["Name"] = Name;
|
|
|
|
|
return t;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(Object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null || GetType() != obj.GetType())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return ID == ((TorznabCategory)obj).ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return ID;
|
2015-07-29 19:30:28 +00:00
|
|
|
|
}
|
2015-07-19 23:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|