Beispiel #1
0
        private long _RegisterUnsupply(PassageCallback passage)
        {
            long id = _UnsupplyIdLandlord.Rent();

            _UnsupplyPassages.Add(new SoulPassage(id, passage));
            return(id);
        }
Beispiel #2
0
            public void GhostTest()
            {
                GhostA          ghostA            = new GhostA();
                IGpiA           gpiA              = ghostA;
                IGhost          ghost             = ghostA;
                PropertyInfo    addSupplyProperty = null;
                PassageCallback addSupplyPassage  = null;

                ghost.AddSupplyNoitfierEvent += (property, passage) =>
                {
                    addSupplyProperty = property;
                    addSupplyPassage  = passage;
                };
                IGpiB gPi = null;

                gpiA.GpiBs.Supply += (gpi) =>
                {
                    gPi = gpi;
                };

                SoulB soulB = new SoulB();

                addSupplyPassage(soulB);


                NUnit.Framework.Assert.AreEqual(soulB, gPi);
            }
Beispiel #3
0
            public void GhostNotifierTest()
            {
                PassageCallback          p1             = null;
                PassageCallback          p2             = null;
                PassageCallback          p3             = null;
                PassageCallback          p4             = null;
                Action <PassageCallback> addSupply      = p => p1 = p;
                Action <PassageCallback> removeSupply   = p => p2 = p;
                Action <PassageCallback> addUnsupply    = p => p3 = p;
                Action <PassageCallback> removeUnsupply = p => p4 = p;
                GhostNotifier <IGpiA>    notifier       = new Regulus.Remote.GhostNotifier <IGpiA>(addSupply, removeSupply, addUnsupply, removeUnsupply);
                INotifier <IGpiA>        gpiNotifier    = notifier as INotifier <IGpiA>;
                Action <IGpiA>           empty          = (gpi) => { };

                gpiNotifier.Supply   += empty;
                gpiNotifier.Supply   -= empty;
                gpiNotifier.Unsupply += empty;
                gpiNotifier.Unsupply -= empty;

                int c1 = p1.GetHashCode();
                int c2 = p2.GetHashCode();

                NUnit.Framework.Assert.AreNotEqual(null, p1);
                NUnit.Framework.Assert.AreNotEqual(null, p2);
                NUnit.Framework.Assert.AreNotEqual(null, p3);
                NUnit.Framework.Assert.AreNotEqual(null, p4);

                NUnit.Framework.Assert.AreNotSame(c1, c2);
                NUnit.Framework.Assert.AreNotSame(p3, p4);
            }
Beispiel #4
0
        internal void Supply(IGhost ghost, long notifier_id)
        {
            PassageCallback passage = _FindSupply(notifier_id);

            if (passage != null)
            {
                passage(ghost);
            }
        }
Beispiel #5
0
        internal void RemoveUnsupply(PropertyInfo info, PassageCallback passage)
        {
            long passageId = _NotifierPassage.UnregisterUnsupply(passage);

            PackageNotifierEvent package = new PackageNotifierEvent();

            package.Entity   = _Ghost.GetID();
            package.Property = _Protocol.GetMemberMap().GetProperty(info);
            package.Passage  = passageId;
            _Requester.Request(ClientToServerOpCode.RemoveNotifierUnsupply, package.ToBuffer(_Protocol.GetSerialize()));
        }
Beispiel #6
0
        private long _UnregisterUnsupply(PassageCallback handler)
        {
            SoulPassage passage = _UnsupplyPassages.FirstOrDefault(p => p.Handler == handler);

            if (passage == null)
            {
                return(0);
            }
            _UnsupplyPassages.Remove(passage);
            return(passage.Id);
        }
Beispiel #7
0
 public long RegisterUnsupply(PassageCallback passage)
 {
     return(_RegisterUnsupply(passage));
 }
Beispiel #8
0
 public long UnregisterSupply(PassageCallback passage)
 {
     return(_UnregisterSupply(passage));
 }
Beispiel #9
0
 public SoulPassage(long id, PassageCallback callback)
 {
     Id      = id;
     Handler = callback;
 }