Exemplo n.º 1
0
        public void OnNext(TClass value)
        {
            value.Sender = _viewModel;

            //uFrame_kbe
            if (Action != null)
            {
                if (System.Threading.Thread.CurrentThread.ManagedThreadId == 1)
                {
                    Action(value);
                    Action.Invoke(value);
                }
                else
                {
                    uFrameKernel.EventAggregator.Publish(new ViewModelCommandExcuteEvent()
                    {
                        Action  = Action,
                        Command = value
                    });
                }
            }
            //

            _signalSubject.OnNext(value);
        }
Exemplo n.º 2
0
 public void ExecuteCommand(ICommand command, object argument, bool isChained = false)
 {
     command.Execute(argument);
     if (_commandsAsObservable != null)
     {
         _commandsAsObservable.OnNext(new CommandInfo(command, argument, isChained));
     }
 }
Exemplo n.º 3
0
    public void Execute(TArgument parameter)
    {
        var arg = parameter;

        Parameter = arg;
        OnOnCommandExecuting();
        Execute();
        _executedSubject.OnNext(arg);
        OnOnCommandExecuted();
    }
Exemplo n.º 4
0
        public void OnNext(TClass value)
        {
            value.Sender = _viewModel;

            if (Action != null)
            {
                Action(value);
            }

            _signalSubject.OnNext(value);
        }
Exemplo n.º 5
0
        public void Subject1Test()
        {
            ISubject <int, string> xs = new SimpleSubject <int, string>(l => l.ToString().PadRight(l, '*'));
            var ys = xs.Monitor("Subject", 1);

            ys.Subscribe();

            xs.OnNext(1);
            Thread.Sleep(1000);
            ys.OnNext(2);
            Thread.Sleep(1000);
            ys.OnNext(3);

            Thread.Sleep(100);
            GC.KeepAlive(ys);
        }
Exemplo n.º 6
0
        public void SimpleSubject_DisposedBehavior()
        {
            var s = new SimpleSubject <int>();

            var d1 = s.Subscribe();

            for (int i = 0; i < 2; i++)
            {
                s.Dispose();

                Assert.ThrowsException <ObjectDisposedException>(() => s.OnNext(42));
                Assert.ThrowsException <ObjectDisposedException>(() => s.OnError(new Exception()));
                Assert.ThrowsException <ObjectDisposedException>(() => s.OnCompleted());

                d1.Dispose();

                Assert.ThrowsException <ObjectDisposedException>(() => s.Subscribe());
            }
        }