mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Version number parsing for XBMC Frodo
This commit is contained in:
parent
5294928878
commit
b747db6b93
7 changed files with 295 additions and 20 deletions
14
NzbDrone.Core/Model/Xbmc/XbmcJsonResult.cs
Normal file
14
NzbDrone.Core/Model/Xbmc/XbmcJsonResult.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Xbmc
|
||||
{
|
||||
public class XbmcJsonResult<T>
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string JsonRpc { get; set; }
|
||||
public T Result { get; set; }
|
||||
}
|
||||
}
|
123
NzbDrone.Core/Model/Xbmc/XbmcVersion.cs
Normal file
123
NzbDrone.Core/Model/Xbmc/XbmcVersion.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Xbmc
|
||||
{
|
||||
public class XbmcVersion : IComparable<XbmcVersion>
|
||||
{
|
||||
public XbmcVersion()
|
||||
{
|
||||
}
|
||||
|
||||
public XbmcVersion(int major)
|
||||
{
|
||||
Major = major;
|
||||
}
|
||||
|
||||
public XbmcVersion(int major, int minor, int patch)
|
||||
{
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
Patch = patch;
|
||||
}
|
||||
|
||||
public int Major { get; set; }
|
||||
public int Minor { get; set; }
|
||||
public int Patch { get; set; }
|
||||
|
||||
public int CompareTo(XbmcVersion other)
|
||||
{
|
||||
if(other.Major > Major)
|
||||
return -1;
|
||||
|
||||
if(other.Major < Major)
|
||||
return 1;
|
||||
|
||||
if (other.Minor > Minor)
|
||||
return -1;
|
||||
|
||||
if (other.Minor < Minor)
|
||||
return 1;
|
||||
|
||||
if (other.Patch > Patch)
|
||||
return -1;
|
||||
|
||||
if (other.Patch < Patch)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static bool operator !=(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
public static bool operator ==(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
var xObj = (Object)x;
|
||||
var yObj = (object)y;
|
||||
|
||||
if (xObj == null || yObj == null)
|
||||
{
|
||||
return xObj == yObj;
|
||||
}
|
||||
|
||||
return x.CompareTo(y) == 0;
|
||||
}
|
||||
|
||||
public static bool operator >(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
return x.CompareTo(y) > 0;
|
||||
}
|
||||
|
||||
public static bool operator <(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
return x.CompareTo(y) < 0;
|
||||
}
|
||||
|
||||
public static bool operator <=(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
return x.CompareTo(y) <= 0;
|
||||
}
|
||||
|
||||
public static bool operator >=(XbmcVersion x, XbmcVersion y)
|
||||
{
|
||||
return x.CompareTo(y) >= 0;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0}.{1}.{2}", Major, Minor, Patch);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Major.GetHashCode();
|
||||
hash = hash * 23 + Minor.GetHashCode();
|
||||
hash = hash * 23 + Patch.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(XbmcVersion other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return (Equals(other.Major, Major) && Equals(other.Minor, Minor) && Equals(other.Patch, Patch));
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != typeof(XbmcVersion)) return false;
|
||||
return Equals((XbmcVersion)obj);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue