本文整理汇总了C#中SafeDictionary.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SafeDictionary.Clear方法的具体用法?C# SafeDictionary.Clear怎么用?C# SafeDictionary.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeDictionary
的用法示例。
在下文中一共展示了SafeDictionary.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sort
public static void Sort(uint updateUID)
{
SortedDictionary<ulong, SortEntry<uint, NobilityInformation>> sortdict = new SortedDictionary<ulong, SortEntry<uint, NobilityInformation>>();
foreach (NobilityInformation info in Board.Values)
{
if (sortdict.ContainsKey(info.Donation))
{
SortEntry<uint, NobilityInformation> entry = sortdict[info.Donation];
entry.Values.Add(info.EntityUID, info);
}
else
{
SortEntry<uint, NobilityInformation> entry = new SortEntry<uint, NobilityInformation>();
entry.Values = new Dictionary<uint, NobilityInformation>();
entry.Values.Add(info.EntityUID, info);
sortdict.Add(info.Donation, entry);
}
}
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>(1000000);
sortedBoard.Clear();
int Place = 0;
foreach (KeyValuePair<ulong, SortEntry<uint, NobilityInformation>> entries in sortdict.Reverse())
{
foreach (KeyValuePair<uint, NobilityInformation> value in entries.Value.Values)
{
Client.GameState client = null;
try
{
int previousPlace = value.Value.Position;
value.Value.Position = Place;
NobilityRank Rank = NobilityRank.Serf;
if (Place > 100)
{
if (value.Value.Donation >= 200000000)
{
Rank = NobilityRank.Earl;
}
else if (value.Value.Donation >= 100000000)
{
Rank = NobilityRank.Baron;
}
else if (value.Value.Donation >= 30000000)
{
Rank = NobilityRank.Knight;
}
}
else
{
if (Place < PhoenixProject.Database.rates.king)
{
//PhoenixProject.ServerBase.Kernel.SendWorldMessage(new PhoenixProject.Network.GamePackets.Message("Congratulation! " + client.Entity.Name + "Donation To King in Nobility Rank!", System.Drawing.Color.White, 2011), PhoenixProject.ServerBase.Kernel.GamePool.Values);
Rank = NobilityRank.King;
//PhoenixProject.Clan.nobmas(client);
// ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To King/Queen in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
//Rank = NobilityRank.King;
}
else if (Place < PhoenixProject.Database.rates.prince)
{
Rank = NobilityRank.Prince;
//PhoenixProject.Clan.nobmas(client);
// ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Prince in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
// Rank = NobilityRank.Prince;
}
else
{
Rank = NobilityRank.Duke;
//PhoenixProject.Clan.nobmas(client);
//ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Duke in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
//Rank = NobilityRank.Duke;
}
}
var oldRank = value.Value.Rank;
value.Value.Rank = Rank;
if (ServerBase.Kernel.GamePool.TryGetValue(value.Key, out client))
{
bool updateTheClient = false;
if (oldRank != Rank)
{
updateTheClient = true;
if (Rank == NobilityRank.Baron)
{
ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Donation To Baron in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
}
if (Rank == NobilityRank.Earl)
{
ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Donation To Earl in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
}
if (Rank == NobilityRank.Duke)
{
ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Donation To Duke in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
}
if (Rank == NobilityRank.Prince)
{
ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " Donation To Prince in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
}
if (Rank == NobilityRank.King)
{
//.........这里部分代码省略.........
示例2: Reincarnation
public Reincarnation(Client.GameState client, byte new_class)
{
if (client.Entity.Level < 130)
return;
_client = client;
RemoveSkill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
#region Low level items
for (byte i = 1; i < 9; i++)
{
if (i != 7)
{
Interfaces.IConquerItem item = client.Equipment.TryGetItem(i);
if (item != null && item.ID != 0)
{
try
{
//client.UnloadItemStats(item, false);
Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
item.Send(client);
client.LoadItemStats(client.Entity);
Database.ConquerItemTable.UpdateItemID(item, client);
}
catch
{
Console.WriteLine("Reborn item problem: " + item.ID);
}
}
}
}
Interfaces.IConquerItem hand = client.Equipment.TryGetItem(5);
if (hand != null)
{
client.Equipment.Remove(5);
client.CalculateStatBonus();
client.CalculateHPBonus();
client.SendStatMessage();
}
else
//client.Screen.send(client.Entity.SpawnPacket, false);
#endregion
#region Remove Extra Skill
if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15 && client.Entity.Class == 15)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.DragonWhirl);
}
if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25 && client.Entity.Class == 25)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.Perseverance);
}
if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45 && client.Entity.Class == 45)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.StarArrow);
}
if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55 && client.Entity.Class == 55)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);
}
if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65 && client.Entity.Class == 65)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.SoulShackle);
}
if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135 && client.Entity.Class == 135)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.AzureShield);
}
if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145 && client.Entity.Class == 145)
{
WontAdd(PhoenixProject.Game.Enums.SkillIDs.HeavenBlade);
}
#endregion
Database.ReincarnationTable.NewReincarnated(client.Entity);
Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
info.UID = client.Entity.UID;
info.Level = client.Entity.Level;
info.Experience = client.Entity.Experience;
ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
client.Entity.FirstRebornClass = client.Entity.SecondRebornClass;
client.Entity.SecondRebornClass = client.Entity.Class;
client.Entity.Class = new_class;
client.Entity.SecondRebornLevel = client.Entity.Level;
client.Entity.Level = 15;
client.Entity.Experience = 0;
client.Entity.Atributes =
(ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornClass, client.Entity.FirstRebornLevel) +
client.ExtraAtributePoints(client.Entity.SecondRebornClass, client.Entity.SecondRebornLevel) + 62);
client.Spells.Clear();
client.Spells = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(100);
switch (client.Entity.FirstRebornClass)
{
case 15:
{
Add(PhoenixProject.Game.Enums.SkillIDs.Cyclone);
Add(PhoenixProject.Game.Enums.SkillIDs.Hercules);
Add(PhoenixProject.Game.Enums.SkillIDs.SpiritHealing);
//.........这里部分代码省略.........
示例3: CancelExtracted
private void CancelExtracted(bool throwOnFirstException, SafeDictionary<CancellationTokenRegistration, Action> callbacks)
{
if (Interlocked.CompareExchange(ref _cancelRequested, 1, 0) == 0)
{
_handle.Set();
UnregisterLinkedTokens();
List<Exception> exceptions = null;
try
{
int id = _currentId;
do
{
Action callback;
if (callbacks.Remove(new CancellationTokenRegistration(id, this), out callback) && callback != null)
{
if (throwOnFirstException)
{
callback();
}
else
{
try
{
callback();
}
catch (Exception exception)
{
if (ReferenceEquals(exceptions, null))
{
exceptions = new List<Exception>();
}
exceptions.Add(exception);
}
}
}
} while (id-- != int.MinValue);
}
finally
{
callbacks.Clear();
}
if (exceptions != null)
{
throw new AggregateException(exceptions);
}
}
}