2016-06-20 10:30:03 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using AutoMapper;
|
2016-07-12 14:57:24 +00:00
|
|
|
|
using PettingZoo.Connection;
|
2016-06-20 10:30:03 +00:00
|
|
|
|
using PettingZoo.Infrastructure;
|
2016-06-18 14:50:32 +00:00
|
|
|
|
|
|
|
|
|
namespace PettingZoo.ViewModel
|
|
|
|
|
{
|
2016-06-21 15:05:14 +00:00
|
|
|
|
public class ConnectionViewModel : BaseViewModel
|
2016-06-18 14:50:32 +00:00
|
|
|
|
{
|
2016-06-21 15:05:14 +00:00
|
|
|
|
private static readonly IMapper ModelMapper = new MapperConfiguration(cfg =>
|
|
|
|
|
cfg.CreateMap<ConnectionInfo, ConnectionViewModel>().ReverseMap()
|
|
|
|
|
).CreateMapper();
|
2016-06-20 10:30:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly DelegateCommand okCommand;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Host { get; set; }
|
|
|
|
|
public string VirtualHost { get; set; }
|
|
|
|
|
public int Port { get; set; }
|
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
|
2016-06-18 18:30:12 +00:00
|
|
|
|
public string Exchange { get; set; }
|
|
|
|
|
public string RoutingKey { get; set; }
|
2016-06-20 10:30:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand OkCommand { get { return okCommand; } }
|
|
|
|
|
|
|
|
|
|
public event EventHandler CloseWindow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ConnectionViewModel()
|
|
|
|
|
{
|
|
|
|
|
okCommand = new DelegateCommand(OkExecute, OkCanExecute);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ConnectionViewModel(ConnectionInfo model) : this()
|
|
|
|
|
{
|
2016-06-20 12:20:37 +00:00
|
|
|
|
ModelMapper.Map(model, this);
|
2016-06-20 10:30:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ConnectionInfo ToModel()
|
|
|
|
|
{
|
2016-06-20 12:20:37 +00:00
|
|
|
|
return ModelMapper.Map<ConnectionInfo>(this);
|
2016-06-20 10:30:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OkExecute()
|
|
|
|
|
{
|
|
|
|
|
if (CloseWindow != null)
|
|
|
|
|
CloseWindow(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool OkCanExecute()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-06-18 14:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|