2016-07-12 14:57:24 +00:00
|
|
|
|
namespace PettingZoo.Infrastructure
|
2016-06-21 15:05:14 +00:00
|
|
|
|
{
|
|
|
|
|
public interface IUserSettingsSerializer
|
|
|
|
|
{
|
|
|
|
|
void Read(UserSettings settings);
|
|
|
|
|
void Write(UserSettings settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ConnectionWindowSettings
|
|
|
|
|
{
|
|
|
|
|
public string LastHost { get; set; }
|
|
|
|
|
public string LastVirtualHost { get; set; }
|
|
|
|
|
public int LastPort { get; set; }
|
|
|
|
|
public string LastUsername { get; set; }
|
|
|
|
|
public string LastPassword { get; set; }
|
|
|
|
|
|
|
|
|
|
public string LastExchange { get; set; }
|
|
|
|
|
public string LastRoutingKey { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ConnectionWindowSettings()
|
|
|
|
|
{
|
|
|
|
|
LastHost = "localhost";
|
|
|
|
|
LastPort = 5672;
|
|
|
|
|
LastVirtualHost = "/";
|
|
|
|
|
LastUsername = "guest";
|
|
|
|
|
LastPassword = "guest";
|
|
|
|
|
|
|
|
|
|
LastExchange = "amqp";
|
|
|
|
|
LastRoutingKey = "#";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class UserSettings
|
|
|
|
|
{
|
|
|
|
|
public ConnectionWindowSettings ConnectionWindow { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IUserSettingsSerializer serializer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UserSettings(IUserSettingsSerializer serializer)
|
|
|
|
|
{
|
|
|
|
|
ConnectionWindow = new ConnectionWindowSettings();
|
|
|
|
|
|
|
|
|
|
this.serializer = serializer;
|
|
|
|
|
serializer.Read(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
|
|
|
|
serializer.Write(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|