81 lines
No EOL
2.7 KiB
C#
81 lines
No EOL
2.7 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace Shuttle.Servers
|
|
{
|
|
public class TargetAppInfo
|
|
{
|
|
public string ConnectionId { get; }
|
|
|
|
public string ShuttleId { get; }
|
|
|
|
public AdobeApplicationType AppType { get; }
|
|
|
|
public int AppMajorVersionNumber { get; }
|
|
|
|
public TargetAppInfo(string connectionId, AdobeApplicationType appType, int appMajorVersionNumber, string shuttleId)
|
|
{
|
|
if (!Enum.IsDefined(typeof(AdobeApplicationType), appType))
|
|
{
|
|
throw new InvalidEnumArgumentException(nameof(appType), (int) appType, typeof(AdobeApplicationType));
|
|
}
|
|
|
|
ConnectionId = connectionId ?? throw new ArgumentNullException(nameof(connectionId));
|
|
AppType = appType;
|
|
AppMajorVersionNumber = appMajorVersionNumber;
|
|
ShuttleId = shuttleId ?? throw new ArgumentNullException(nameof(shuttleId));
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (ReferenceEquals(this, obj))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
var otherAppInfo = obj as TargetAppInfo;
|
|
return otherAppInfo != null &&
|
|
ConnectionId == otherAppInfo.ConnectionId &&
|
|
AppType == otherAppInfo.AppType &&
|
|
AppMajorVersionNumber == otherAppInfo.AppMajorVersionNumber &&
|
|
ShuttleId == otherAppInfo.ShuttleId;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
var hashCode = -582183502;
|
|
hashCode = hashCode ^ ConnectionId.GetHashCode();
|
|
hashCode = hashCode ^ AppType.GetHashCode();
|
|
hashCode = hashCode ^ AppMajorVersionNumber.GetHashCode();
|
|
hashCode = hashCode ^ ShuttleId.GetHashCode();
|
|
return hashCode;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{AppType}-{AppMajorVersionNumber}-{ShuttleId}";
|
|
}
|
|
|
|
public static TargetAppInfo Empty { get; } = new TargetAppInfo(connectionId: string.Empty, appType: AdobeApplicationType.Unknown, appMajorVersionNumber: 0, shuttleId: "<no target>");
|
|
|
|
public static bool IsEmpty(TargetAppInfo targetAppInfo)
|
|
{
|
|
return Empty.Equals(targetAppInfo);
|
|
}
|
|
|
|
public static bool operator ==(TargetAppInfo target1, TargetAppInfo target2)
|
|
{
|
|
if (ReferenceEquals(target1, null))
|
|
{
|
|
return ReferenceEquals(target2, null);
|
|
}
|
|
|
|
return target1.Equals(target2);
|
|
}
|
|
|
|
public static bool operator !=(TargetAppInfo target1, TargetAppInfo target2)
|
|
{
|
|
return !(target1 == target2);
|
|
}
|
|
}
|
|
} |