2018-08-05 14:28:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.CustomFormats
|
|
|
|
|
{
|
|
|
|
|
public class CustomFormat : ModelBase, IEquatable<CustomFormat>
|
|
|
|
|
{
|
|
|
|
|
public CustomFormat()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CustomFormat(string name, params string[] tags)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
FormatTags = tags.Select(t => new FormatTag(t)).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 21:47:33 +00:00
|
|
|
|
public static CustomFormat None => new CustomFormat
|
|
|
|
|
{
|
|
|
|
|
Id = 0,
|
|
|
|
|
Name = "None",
|
|
|
|
|
FormatTags = new List<FormatTag>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<FormatTag> FormatTags { get; set; }
|
2018-08-05 14:28:05 +00:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(CustomFormat other)
|
|
|
|
|
{
|
2020-01-22 21:47:33 +00:00
|
|
|
|
if (other is null)
|
2019-12-22 22:08:53 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-05 14:28:05 +00:00
|
|
|
|
return int.Equals(Id, other.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
2020-01-22 21:47:33 +00:00
|
|
|
|
if (obj is null)
|
2019-12-22 22:08:53 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ReferenceEquals(this, obj))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (obj.GetType() != GetType())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Equals((CustomFormat)obj);
|
2018-08-05 14:28:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
2020-01-22 21:47:33 +00:00
|
|
|
|
return Id;
|
2018-09-10 19:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-05 14:28:05 +00:00
|
|
|
|
}
|