public void ET_Repository_Submit_ChildrenOnly() { var repo = RF.Concrete <PBSTypeRepository>(); using (RF.TransactionScope(repo)) { var root = new PBSType(); var pbs = new PBS(); root.PBSList.Add(pbs); repo.Save(root); Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Unchanged); int count = 0; EventHandler <Rafy.Logger.DbAccessedEventArgs> handler = (o, e) => { if (e.ConnectionSchema == repo.RdbDataProvider.DbSetting) { count++; } }; Logger.DbAccessed += handler; pbs.Name = "DDDDDDDDDD"; Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Modified); var c = count; repo.Save(root); Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(count == c + 1, "只进行了一次数据访问,即子对象的保存。"); Logger.DbAccessed -= handler; } }
public bool Contains(PBS entity) { return base.Contains(entity); }
public int IndexOf(PBS entity) { return base.IndexOf(entity); }
public void Add(PBS entity) { base.Add(entity); }
public bool Remove(PBS entity) { return base.Remove(entity); }
public void Insert(int index, PBS entity) { base.Insert(index, entity); }
public void ET_Repository_Submit_ChildrenOnly() { var repo = RF.Concrete<PBSTypeRepository>(); using (RF.TransactionScope(repo)) { var root = new PBSType(); var pbs = new PBS(); root.PBSList.Add(pbs); repo.Save(root); Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Unchanged); int count = 0; EventHandler<Rafy.Logger.DbAccessedEventArgs> handler = (o, e) => { if (e.ConnectionSchema == RdbDataProvider.Get(repo).DbSetting) count++; }; Logger.DbAccessed += handler; pbs.Name = "DDDDDDDDDD"; Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Modified); var c = count; repo.Save(root); Assert.IsTrue(root.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(pbs.PersistenceStatus == PersistenceStatus.Unchanged); Assert.IsTrue(count == c + 1, "只进行了一次数据访问,即子对象的保存。"); Logger.DbAccessed -= handler; } }
public void EndGame(bool gmtrig) { this.Active = false; InvalidateProperties(); if (gmtrig == false) { if (m_Team1 > 0 && m_Team2 == 0 && m_Team3 == 0 && m_Team4 == 0) { World.Broadcast(0x22, true, m_Team1Name + " has won in Paintball!"); foreach (Mobile mob in Announcers) { mob.PublicOverheadMessage(MessageType.Regular, 0x22, false, m_Team1Name + " has won"); } } else if (m_Team2 > 0 && m_Team1 == 0 && m_Team3 == 0 && m_Team4 == 0) { World.Broadcast(0x22, true, "Team 2 has won in Paintball!"); foreach (Mobile mob in Announcers) { mob.PublicOverheadMessage(MessageType.Regular, 0x22, false, m_Team2Name + " has won"); } } else if (m_Team3 > 0 && m_Team1 == 0 && m_Team2 == 0 && m_Team4 == 0) { World.Broadcast(0x22, true, "Team 3 has won in Paintball!"); foreach (Mobile mob in Announcers) { mob.PublicOverheadMessage(MessageType.Regular, 0x22, false, m_Team3Name + " has won"); } } else if (m_Team4 > 0 && m_Team1 == 0 && m_Team2 == 0 && m_Team3 == 0) { World.Broadcast(0x22, true, "Team 4 has won in Paintball!"); foreach (Mobile mob in Announcers) { mob.PublicOverheadMessage(MessageType.Regular, 0x22, false, m_Team4Name + " has won"); } } else { World.Broadcast(0x22, true, "Error:"); World.Broadcast(0x22, true, m_Team1.ToString() + " = team 1"); World.Broadcast(0x22, true, m_Team2.ToString() + " = team 2"); World.Broadcast(0x22, true, m_Team3.ToString() + " = team 3"); World.Broadcast(0x22, true, m_Team4.ToString() + " = team 4"); } } else if (gmtrig == true) { World.Broadcast(0x22, true, "The Paintball game was ended by the GM. No winner was declared."); } ArrayList MobDel = new ArrayList(); if (Players != null) { foreach (Mobile pm in Players) { pm.SendMessage("The game has ended."); pm.Hidden = true; pm.Warmode = false; pm.Frozen = false; if (gmtrig == false) { GivePrizes(pm); } Item PBSI; Item LPackI; Item IPackI; Container bank = pm.FindBankNoCreate(); PBSI = bank.FindItemByType(typeof(PBPlayerStorage)); LPackI = bank.FindItemByType(typeof(LayerPack)); IPackI = bank.FindItemByType(typeof(ItemsPack)); pm.AddToBackpack(PBSI); pm.AddToBackpack(LPackI); pm.AddToBackpack(IPackI); List <Item> Layer = LPackI.Items; if (Layer != null && LPackI != null) { if (Layer.Count > 0) { for (int i = Layer.Count - 1; i >= 0; --i) { if (i >= Layer.Count) { continue; } pm.AddItem(Layer[i]); } } LPackI.Delete(); } List <Item> Pack = IPackI.Items; if (Pack != null && IPackI != null) { if (Pack.Count > 0) { for (int i = Pack.Count - 1; i >= 0; --i) { if (i >= Pack.Count) { continue; } pm.AddToBackpack(Pack[i]); } } IPackI.Delete(); } if (PBSI != null) { PBPlayerStorage PBStorage = PBSI as PBPlayerStorage; if (PBStorage != null) { PBStorage.Use(pm); } } ArrayList toDelete = new ArrayList(); foreach (Item litem in pm.Items) { if (litem is PBArmor || litem is PBWeapon || litem is PaintBall || litem is Cloak || litem is Squash || litem is PBGrenade) { toDelete.Add(litem); } } if (pm.Backpack != null) { foreach (Item bitem in pm.Backpack.Items) { if (bitem is PBArmor || bitem is PBWeapon || bitem is PaintBall || bitem is Cloak || bitem is Squash || bitem is PBGrenade) { toDelete.Add(bitem); } } } foreach (Item ditem in toDelete) { ditem.Delete(); } } } if (DeadPlayers != null) { foreach (Mobile dm in DeadPlayers) { dm.SendMessage("The game has ended."); dm.Hidden = true; dm.Warmode = false; dm.Frozen = false; if (gmtrig == false) { GivePrizes(dm); } Item PBSI; PBPlayerStorage PBS; Item LPackI; Item IPackI; Container bank = dm.FindBankNoCreate(); PBSI = bank.FindItemByType(typeof(PBPlayerStorage)); LPackI = bank.FindItemByType(typeof(LayerPack)); IPackI = bank.FindItemByType(typeof(ItemsPack)); dm.AddToBackpack(PBSI); dm.AddToBackpack(LPackI); dm.AddToBackpack(IPackI); PBS = (PBPlayerStorage)PBSI; List <Item> Layer = LPackI.Items; if (Layer != null && LPackI != null) { if (Layer.Count > 0) { for (int i = Layer.Count - 1; i >= 0; --i) { if (i >= Layer.Count) { continue; } dm.AddItem(Layer[i]); } } LPackI.Delete(); } List <Item> Pack = IPackI.Items; if (Pack != null && IPackI != null) { if (Pack.Count > 0) { for (int i = Pack.Count - 1; i >= 0; --i) { if (i >= Pack.Count) { continue; } dm.AddToBackpack(Pack[i]); } } IPackI.Delete(); } ArrayList toDelete = new ArrayList(); foreach (Item item in dm.Items) { if (item is PBArmor || item is PBWeapon || item is PaintBall || item is Cloak || item is Squash || item is PBGrenade) { toDelete.Add(item); } } if (dm.Backpack != null) { foreach (Item bpitem in dm.Backpack.Items) { if (bpitem is PBArmor || bpitem is PBWeapon || bpitem is PaintBall || bpitem is Cloak || bpitem is Squash || bpitem is PBGrenade) { toDelete.Add(bpitem); } if (PBS != null) { PBS.Use(dm); } } } if (toDelete != null) { foreach (Item item in toDelete) { item.Delete(); } } } } if (NpcPlayers != null) { foreach (Mobile npc in NpcPlayers) { MobDel.Add(npc); } NpcPlayers.Clear(); NpcPlayers = new ArrayList(); } if (MobDel != null) { foreach (Mobile Mob in MobDel) { if (Mob != null) { Mob.Delete(); } } } if (Players != null) { Players.Clear(); Players = new ArrayList(); } if (Npcs != null) { Npcs.Clear(); } if (m_WinnersPrizes != null) { m_WinnersPrizes.Clear(); } if (m_Team1List != null) { m_Team1List.Clear(); } if (m_Team2List != null) { m_Team2List.Clear(); } if (m_Team3List != null) { m_Team3List.Clear(); } if (m_Team4List != null) { m_Team4List.Clear(); } m_Team1 = 0; m_Team2 = 0; m_Team3 = 0; m_Team4 = 0; UpdateTeams(); m_CurrentTeam = 0; Players = new ArrayList(); m_Npcs = new ArrayList(); m_Team1List = new ArrayList(); m_Team2List = new ArrayList(); m_Team3List = new ArrayList(); m_Team4List = new ArrayList(); NpcPlayers = new ArrayList(); m_WinnersPrizes = new ArrayList(); DeadPlayers = new ArrayList(); Reset(); /* if( m_Timer != null ) * m_Timer.Stop(); */ }