示例#1
0
 internal void _Join(Peer peer, IBootable bootable)
 {
     lock(_Peers)
         _Peers.Add(peer);
     peer.DisconnectEvent += () => { _Leave(peer, peer); };
     bootable.Launch();
 }
示例#2
0
 internal void _Join(Peer peer, IBootable bootable)
 {
     lock (_Peers)
     {
         _Peers.Add(peer);
         peer.DisconnectEvent += () => { _Leave(peer, peer); };
     }
     bootable.Launch();
 }
示例#3
0
 internal void _Leave(Peer peer, IBootable bootable)
 {
     lock(_Peers)
     {
         if (_Peers.Remove(peer))
         {
             bootable.Shutdown();
         }
         else
         {
             throw new Exception("no peer shutdown.");
         }
     }
 }
示例#4
0
 internal void _Leave(Peer peer, IBootable bootable)
 {
     lock (_Peers)
     {
         if (_Peers.Remove(peer))
         {
             bootable.Shutdown();
         }
         else
         {
             if (_Peers.Count > 0)
             {
                 throw new Exception("no peer shutdown.");
             }
         }
     }
 }
示例#5
0
        public void TestGPIBinder()
        {
            Command      command  = new Command();
            IBinderTest  tester   = Substitute.For <IBinderTest>();
            TestNotifier notifier = new TestNotifier(tester);


            GPIBinder <IBinderTest> binder = new GPIBinder <IBinderTest>(notifier, command);
            IBootable boot = binder;

            boot.Launch();


            binder.Bind(t => t.Function1());
            binder.Bind <int>((t, arg) => t.Function2(arg));
            bool returnValue    = false;
            int  returnProperty = 0;

            binder.Bind(t => t.Function3(), ret => { returnValue = true; });

            binder.Bind(t => t.Property1, ret => { returnProperty = 12345; });

            notifier.InvokeSupply();

            command.Run("0Function1", new string[0]);
            command.Run("0Function2", new string[] { "10" });
            command.Run("0Function3", new string[0]);
            command.Run("0Property1", new string[0]);



            boot.Shutdown();

            tester.Received().Function1();
            tester.Received().Function2(Arg.Any <int>());

            NUnit.Framework.Assert.AreEqual(true, returnValue);
            NUnit.Framework.Assert.AreEqual(12345, returnProperty);
        }
示例#6
0
文件: Launcher.cs 项目: bmjoy/Regulus
 public void Push(IBootable laucnher)
 {
     _Launchers.Add(laucnher);
 }
示例#7
0
 public void Push(IBootable laucnher)
 {
     _Launchers.Add(laucnher);
 }