76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
using System;
|
|
using UAF;
|
|
|
|
namespace Plugin
|
|
{
|
|
[Serializable]
|
|
public class EngineConnectionSettings : IEquatable<EngineConnectionSettings>
|
|
{
|
|
private const string _localhost = "127.0.0.1";
|
|
private const string _defaultHostName = "Default PC Host";
|
|
|
|
private static readonly EngineConnectionSettings _default = new EngineConnectionSettings(1001, Localhost, PlatformId.PC, _defaultHostName);
|
|
private static EngineConnectionSettings _lastSelected = null;
|
|
|
|
public EngineConnectionSettings()
|
|
{
|
|
Port = 0;
|
|
Target = default(PlatformId);
|
|
Ip = null;
|
|
}
|
|
|
|
public EngineConnectionSettings(ushort port, string ip, PlatformId target, string connectionName)
|
|
{
|
|
Port = port;
|
|
Target = target;
|
|
Ip = ip;
|
|
ConnectionName = connectionName;
|
|
}
|
|
|
|
public string Ip { get; set; }
|
|
|
|
public ushort Port { get; set; }
|
|
|
|
public PlatformId Target { get; set; }
|
|
|
|
public string ConnectionName { get; set;}
|
|
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
if (Ip != null)
|
|
{
|
|
if (string.IsNullOrEmpty(ConnectionName))
|
|
{
|
|
return string.Format("{0} : {1} - [{2}]", Ip, Port, Target);
|
|
}
|
|
return string.Format("{0} ({1}:{2},{3})", ConnectionName, Ip, Port, Target);
|
|
}
|
|
return "Uninitialized ip adress";
|
|
}
|
|
}
|
|
|
|
|
|
public static EngineConnectionSettings Default
|
|
{
|
|
get { return _default; }
|
|
}
|
|
|
|
public static string Localhost
|
|
{
|
|
get { return _localhost; }
|
|
}
|
|
|
|
public static EngineConnectionSettings LastSelected
|
|
{
|
|
get { return _lastSelected; }
|
|
set { _lastSelected = value; }
|
|
}
|
|
|
|
public bool Equals(EngineConnectionSettings other)
|
|
{
|
|
return (Port == other.Port) && (string.Compare(Ip, other.Ip, StringComparison.Ordinal) == 0) && (Target == other.Target);
|
|
}
|
|
}
|
|
}
|