Mercurial > silverbladetech
view Messaging/Server/UI/MainWindowViewModel.cs @ 29:9919ee227c93
msmq added
author | adminsh@apollo |
---|---|
date | Wed, 21 Mar 2012 22:09:18 +0000 |
parents | 4c0dea4760c5 |
children | 7d9de5746f18 |
line wrap: on
line source
using System.Windows.Input; using Common; using Common.Logger; using Common.Messages; 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 MessageEndPoint<MsmqClientMessage, MsmqLogMessage> MsmqEndPoint { get; set; } public MessageEndPoint<SocketClientMessage, SocketLogMessage> SocketEndPoint { get; set; } public MessageEndPoint<RabbitClientMessage, RabbitLogMessage> RabbitEndPoint { get; set; } public MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage> RabbitProtoEndPoint { get; set; } #region Constructor public MainWindowViewModel() { InitMsmqEndPoint(Settings.MsmqQueueName); //InitSocketEndPoint(Settings.SocketsPortNumber); InitRabbitEndPoint(Settings.RabbitPortNumber, Settings.RabbitQueueName); InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); CloseCommand = new RelayCommand(CloseCommandExecute); } #endregion private void InitMsmqEndPoint(string queueName) { IListener listener = new MsmqListener(queueName); MsmqEndPoint = new MessageEndPoint<MsmqClientMessage, MsmqLogMessage>(listener) { DisplayText = "Microsoft Message Queue", ToolTip = string.Format("Listening on msmq queue ({0})", queueName) }; } private void InitSocketEndPoint(int port) { IListener listener = new AsyncSocketListener(port); SocketEndPoint = new MessageEndPoint<SocketClientMessage, SocketLogMessage>(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 MessageEndPoint<RabbitClientMessage, RabbitLogMessage>(listener) { DisplayText = "RabbitMQ", ToolTip = "Listening..." + port }; } private void InitRabbitProtoEndPoint(int port) { IListener listener = null; RabbitProtoEndPoint = new MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage>(listener) { DisplayText = "RabbitMQ with Protobuf-net", ToolTip = "Listening...." + port }; } private void CloseCommandExecute() { Log.Write("Closing command executed"); Application.Current.Shutdown(); } } }