当前位置: 首页>>代码示例>>C#>>正文


C# Messenger类代码示例

本文整理汇总了C#中Messenger的典型用法代码示例。如果您正苦于以下问题:C# Messenger类的具体用法?C# Messenger怎么用?C# Messenger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Messenger类属于命名空间,在下文中一共展示了Messenger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchText_KeyUp

        //Currently used to do manual SQL commands from program.
        private void SearchText_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (SearchText.Text.Equals("send"))
                {
                    Messenger m = new Messenger();
                    m.sendSelect("SELECT * FROM `keys`;", "keys");
                }
                else
                {
                    Messenger m = new Messenger();

                    string[] parsed = SearchText.Text.Split(';');
                    string username = parsed[0];
                    string password = parsed[1];

                    if (m.login(username, password))
                        SearchText.Text = "Logged in.";
                    else
                        SearchText.Text = "Invalid.";
                    //m.test();
                }

               // SearchText.Text = "";
            }

        }
开发者ID:tylorhl,项目名称:NetworkManager,代码行数:29,代码来源:SearchBox.xaml.cs

示例2: FlyoutStaysOpenIfWanted

        public void FlyoutStaysOpenIfWanted()
        {
            // Arrange
            var currentProject = new ProjectViewModel( new Project { Id = 123 } );
            var messenger = new Messenger();
            var todoRepoMock = new Mock<ITodoRepository>();

            bool messageReceived = false;
            messenger.Register<FlyoutMessage>( this, msg => { if( msg.FlyoutName == FlyoutMessage.AddEntryFlyoutName ) messageReceived = true; } );

            var vm = new AddEntryViewModel( Enumerable.Empty<TagViewModel>(), currentProject, todoRepoMock.Object, messenger )
            {
                Summary = "summary"
            };

            // Act
            vm.StayOpen = true;
            vm.AddCommand.Execute( null );
            bool stay = messageReceived;

            vm.Summary = "summary";
            vm.StayOpen = false;
            vm.AddCommand.Execute( null );
            bool dontStay = messageReceived;

            // Assert
            Assert.IsFalse( stay );
            Assert.IsTrue( dontStay );
        }
开发者ID:TheSylence,项目名称:GSD,代码行数:29,代码来源:AddEntryViewModelTests.cs

示例3: Setup

        public void Setup()
        {
            _messenger = new Messenger();

            _productsServiceMock = new Mock<IProductsService>();
            _viewModel = new ProductListViewModel(_messenger, _productsServiceMock.Object);
        }
开发者ID:TristanRhodes,项目名称:SampleApp,代码行数:7,代码来源:ProductListViewModelTests.cs

示例4: CommunicatorIntegration

        public CommunicatorIntegration()
        {
            try
            {
                m_Messenger = new Messenger();
            }
            catch (Exception)
            {
                throw new CommunicatorNotOpenException();
            }

            m_ServiceID = m_Messenger.MyServiceId;

            try
            {
                m_Messenger.GetContact("[email protected]", m_ServiceID);
            }
            catch (Exception)
            {
                throw new CommunicatorNotLoggedInToRedgateException();
            }

            m_SubscribedContacts = new Dictionary<string, IMessengerContact>();

            m_Messenger.OnContactStatusChange += communicator_OnContactStatusChange;
        }
开发者ID:rba100,项目名称:foosnet,代码行数:26,代码来源:CommunicatorIntegration.cs

示例5: AddUsesCorrectValues

        public void AddUsesCorrectValues()
        {
            // Arrange
            var tags = new[]
            {
                new TagViewModel( new Tag {Id = 1, Name = "Tag1"} ),
                new TagViewModel( new Tag {Id = 2, Name = "Tag2"} )
            };

            var currentProject = new ProjectViewModel( new Project { Id = 123 } );

            var messenger = new Messenger();
            bool addMessageReceived = false;
            messenger.Register<EntryAddedMessage>( this, msg => addMessageReceived = true );

            var todoRepoMock = new Mock<ITodoRepository>();
            todoRepoMock.Setup( x => x.Add( It.Is<Todo>( t => t.Summary.Equals( "summary" ) && t.Details.Equals( "details" ) && t.Project.Id == 123 ) ) ).Verifiable();
            todoRepoMock.Setup( x => x.Update( It.Is<Todo>( t => t.Tags.First().Id == 2 ) ) ).Verifiable();

            var vm = new AddEntryViewModel( tags, currentProject, todoRepoMock.Object, messenger )
            {
                Summary = "summary",
                Details = "details"
            };

            // Act
            vm.Tags[1].IsSelected = true;
            vm.AddCommand.Execute( null );

            // Assert
            todoRepoMock.VerifyAll();
            Assert.IsTrue( addMessageReceived );
        }
开发者ID:TheSylence,项目名称:GSD,代码行数:33,代码来源:AddEntryViewModelTests.cs

示例6: Main

        static void Main()
        {
            Directory.CreateDirectory(LogDir);

            var messenger = new Messenger();

            foreach (var contact in EmailAddresses
                                    .Select(emailAddress => messenger.GetContact(emailAddress, messenger.MyServiceId)))
            {
                Contacts.Add(contact);

                Log(contact);

                // Don't release the COM object of contact here
                // or OnContactStatusChange will not be raised.
            }

            messenger.OnContactStatusChange += (contact, _) => Log((IMessengerContactAdvanced)contact);

            Console.ReadLine();

            foreach (var contact in Contacts)
            {
                Marshal.FinalReleaseComObject(contact);
            }

            Marshal.FinalReleaseComObject(messenger);
        }
开发者ID:tatsuya,项目名称:office-communicator-status-logger,代码行数:28,代码来源:Program.cs

示例7: Messager_Unsubscription_Test

		public void Messager_Unsubscription_Test(int countSend)
		{
			var subscriber1 = new FakeSubscriber();
			var subscriber2 = new FakeSubscriber();
			var message = new FakeOneMessage { Text = "Test message" };
			var messenger = new Messenger();
			byte firstSubscriberNumber = 0;
			byte secondSubscriberNumber = 0;

			messenger.Subscribe<FakeOneMessage>(subscriber1, (s, m) =>
				{
					firstSubscriberNumber++;
					messenger.Unsubscribe<FakeOneMessage>(subscriber1);
				});
			messenger.Subscribe<FakeOneMessage>(subscriber2, (s, m) =>
				{
					secondSubscriberNumber++;
				});
			
			for (int i = 0; i < countSend; i++)
			{
				messenger.Send(message);
			}

			Assert.AreEqual(1, firstSubscriberNumber);
			Assert.AreEqual(countSend, secondSubscriberNumber);
		}
开发者ID:wcoder,项目名称:XForms.Utils,代码行数:27,代码来源:MessagerTests.cs

示例8: TestMultipleRecipients

        public void TestMultipleRecipients()
        {
            var messenger = new Messenger();
            var recipient1 = new OldTestRecipient();
            var recipient2 = new OldTestRecipient();
            var recipient3 = new OldTestRecipient();

            messenger.Register(recipient1, typeof(OldTestMessage));
            messenger.Register(recipient2, typeof(OldTestMessage));
            messenger.Register(recipient3, typeof(OldTestMessage));

            Assert.IsNull(recipient1.Sender);
            Assert.IsNull(recipient1.Content);
            Assert.IsNull(recipient2.Content);
            Assert.IsNull(recipient2.Sender);
            Assert.IsNull(recipient3.Content);
            Assert.IsNull(recipient3.Sender);

            const string TestString = "Hello world";
            var message = new OldTestMessage(this, TestString);
            messenger.Broadcast(message);

            Assert.AreEqual(TestString, recipient1.Content);
            Assert.AreEqual(this, recipient1.Sender);
            Assert.AreEqual(TestString, recipient2.Content);
            Assert.AreEqual(this, recipient2.Sender);
            Assert.AreEqual(TestString, recipient3.Content);
            Assert.AreEqual(this, recipient3.Sender);
        }
开发者ID:ssickles,项目名称:archive,代码行数:29,代码来源:OldMessengerTest.cs

示例9: NaviMessengerService

        public NaviMessengerService()
        {
            naviMessenger = new Messenger(new NaviHandler(this));
            InitEnvParameters();
            ConnectPIC32();

            //Create navigation algorithms thread 
            ThreadAlgorithm = new Thread(new ThreadStart(algorithms));
            ThreadAlgorithm.IsBackground = true;
            ThreadAlgorithm.Priority = System.Threading.ThreadPriority.AboveNormal;

            //Init timer1
            timer1 = new System.Timers.Timer();
            timer1.Interval = 200;
            timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Tick);
            timer1.Stop();
            //Init manual mode timer
            ManModeTimer = new System.Timers.Timer();
            ManModeTimer.Interval = 100;
            ManModeTimer.Elapsed += new System.Timers.ElapsedEventHandler(ManModeTimerHandler);
            ManModeTimer.Stop();
            //Read config from default.set and process map
            ProcessConfigMap();
            //Connect beacon and start sendcoordinatetimer and TagDataRecvTimer
            ConnectBeacon();
        }
开发者ID:pochuntsai,项目名称:navi-service,代码行数:26,代码来源:NaviService.cs

示例10: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            XmlConfigurator.Configure();

            _logger.Info("[START]");
            _logger.Info("setup dependency injection container");
            Container = new UnityContainer();

            _logger.Info("setup database");
            string directory = Environment.GetFolderPath(
                Environment.SpecialFolder.LocalApplicationData);
            _logger.Info("database directory: " + directory);
            _dbContext = new NDatabaseConnector(directory);

            //database registration
            Container.RegisterInstance(typeof (IDataAccessLayer), _dbContext);

            //service registrations
            Container.RegisterType<ICryptographyService, CryptographyService>();
            Container.RegisterType<IDropboxService, DropboxService>();

            //registraions utils
            //only one instance from messenger can exists! (recipient problems..)
            _logger.Info("register messenger instance");
            var messenger = new Messenger();
            Container.RegisterInstance(typeof (IMessenger), messenger);

            _logger.Info("show login view");
            var loginView = Container.Resolve<LoginView>();
            loginView.Show();
        }
开发者ID:wasteland540,项目名称:SecureFileShare,代码行数:31,代码来源:App.xaml.cs

示例11: MainWindowViewModel

 public MainWindowViewModel(Messenger messenger)
 {
     Workspaces = new ObservableCollection<IWorkspace>();
     Workspaces.CollectionChanged += Workspaces_CollectionChanged;
     SearchCustomerCommand = new RelayCommand(SearchCustomer);
     CreateCustomerCommand = new RelayCommand(() => messenger.Send(new OpenDialogWindowMessage(new CustomerViewModel(new Customer()), r => MessageBox.Show(r.ToString()))));
 }
开发者ID:smartinz,项目名称:randomhacking,代码行数:7,代码来源:MainWindowViewModel.cs

示例12: Control_Loaded

        private void Control_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var messenger = new Messenger();

            messenger.Register<UpdateHeaderMessage>(this, m => UpdateHeader(m));

            DataContext = new ControlViewModel(messenger);
        }
开发者ID:gotdibbs,项目名称:magician,代码行数:8,代码来源:Control.xaml.cs

示例13: ControlViewModel

        public ControlViewModel(Messenger messenger)
        {
            _messenger = messenger;

            Connect();

            ConnectCommand = new RelayCommand(() => Connect());
        }
开发者ID:gotdibbs,项目名称:magician,代码行数:8,代码来源:ControlViewModel.cs

示例14: OnBind

        public override IBinder OnBind(Intent intent)
        {
            if (intent.GetParcelableExtra("MESSENGER") != null) {
             this.outMessenger = (Messenger) intent.GetParcelableExtra("MESSENGER");
            }

            return inMessenger.Binder;
        }
开发者ID:mmfraser,项目名称:dissertation,代码行数:8,代码来源:ComputeService.cs

示例15: Initialise

    public void Initialise(UserInterface userInterface)
    {
        UserInterface = userInterface;
        Connection = gameObject.AddComponent<Connection>();
        MessageHandler = new MessageHandler(Connection);
        Messenger = new Messenger(Connection);

        MessageHandler.OnAny += MessageHandler_OnMessage;
    }
开发者ID:Trainfire,项目名称:Drawesome,代码行数:9,代码来源:Client.cs


注:本文中的Messenger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。