You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/src/NzbDrone.Core/Indexers/IndexerCategory.cs

41 lines
1.2 KiB

using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace NzbDrone.Core.Indexers
{
public class IndexerCategory
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<IndexerCategory> SubCategories { get; private set; }
public IndexerCategory() => SubCategories = new List<IndexerCategory>();
public IndexerCategory(int id, string name)
{
Id = id;
Name = name;
SubCategories = new List<IndexerCategory>();
}
public bool Contains(IndexerCategory cat) =>
Equals(this, cat) || SubCategories.Contains(cat);
public JToken ToJson() =>
new JObject
{
["ID"] = Id,
["Name"] = Name
};
public override bool Equals(object obj) => (obj as IndexerCategory)?.Id == Id;
// Get Hash code should be calculated off read only properties.
// ID is not readonly
public override int GetHashCode() => Id;
public IndexerCategory CopyWithoutSubCategories() => new IndexerCategory(Id, Name);
}
}