Mercurial > silverbladetech
view Messaging/Server/UI/MainWindowViewModel.cs @ 28:4c0dea4760c5
RabbitMq working
author | adminsh@apollo |
---|---|
date | Wed, 21 Mar 2012 20:29:04 +0000 |
parents | 96fdf58e05b4 |
children | 9919ee227c93 |
line wrap: on
line source
using System.Windows.Input; using Common; using Common.Logger; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System.Windows; using Server.EndPoints; using Server.Interfaces; using Server.Listeners; namespace Server.UI { public class MainWindowViewModel : ViewModelBase { #region Properties #region OverrideSwitch public const string OverrideSwitchPropertyName = "OverrideSwitch"; private bool? _overrideSwitch = false; public bool? OverrideSwitch { get { return _overrideSwitch; } set { if (_overrideSwitch == value) return; var oldValue = _overrideSwitch; _overrideSwitch = value; RaisePropertyChanged(() => OverrideSwitch, oldValue, value, false); } } #endregion #endregion public ICommand CloseCommand { get; set; } public BaseEndPoint SocketEndPoint { get; set; } public BaseEndPoint RabbitEndPoint { get; set; } public BaseEndPoint RabbitProtoEndPoint { get; set; } #region Constructor public MainWindowViewModel() { InitSocketEndPoint(Settings.SocketsPortNumber); InitRabbitEndPoint(Settings.RabbitPortNumber, Settings.QueueName); InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); CloseCommand = new RelayCommand(CloseCommandExecute); } #endregion private void InitSocketEndPoint(int port) { IListener listener = new AsyncSocketListener(port); SocketEndPoint = new SocketEndPoint(listener) { DisplayText = "Async Sockets", ToolTip = "Listening over TCP/IP on socket localhost:" + port }; } private void InitRabbitEndPoint(int port, string queueName) { IListener listener = new RabbitQueueListener(port, queueName); RabbitEndPoint = new RabbitEndPoint(listener) { DisplayText = "RabbitMQ", ToolTip = "Listening..." + port }; } private void InitRabbitProtoEndPoint(int port) { IListener listener = null; RabbitProtoEndPoint = new RabbitProtoEndPoint(listener) { DisplayText = "RabbitMQ with Protobuf-net", ToolTip = "Listening...." + port }; } private void CloseCommandExecute() { Log.Write("Closing command executed"); Application.Current.Shutdown(); } } }