1
0
mirror of synced 2024-11-15 01:33:51 +00:00
PettingZoo/ViewModel/ConnectionViewModel.cs

67 lines
1.5 KiB
C#
Raw Normal View History

2016-06-20 10:30:03 +00:00
using System;
using System.Windows.Input;
using AutoMapper;
using PettingZoo.Infrastructure;
using PettingZoo.Model;
2016-06-18 14:50:32 +00:00
namespace PettingZoo.ViewModel
{
2016-06-18 18:30:12 +00:00
public class ConnectionViewModel
2016-06-18 14:50:32 +00:00
{
2016-06-20 10:30:03 +00:00
private static IMapper modelMapper = new MapperConfiguration(cfg =>
{
cfg.CreateMap<ConnectionInfo, ConnectionViewModel>();
cfg.CreateMap<ConnectionViewModel, ConnectionInfo>();
}).CreateMapper();
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()
{
modelMapper.Map(model, this);
}
public ConnectionInfo ToModel()
{
return modelMapper.Map<ConnectionInfo>(this);
}
private void OkExecute()
{
if (CloseWindow != null)
CloseWindow(this, EventArgs.Empty);
}
private bool OkCanExecute()
{
return true;
}
2016-06-18 14:50:32 +00:00
}
}