diff --git a/Projects/Server.Tests/Utility/TestStringHelpers.cs b/Projects/Server.Tests/Utility/TestStringHelpers.cs index df5c2151d..7570fb722 100644 --- a/Projects/Server.Tests/Utility/TestStringHelpers.cs +++ b/Projects/Server.Tests/Utility/TestStringHelpers.cs @@ -10,7 +10,7 @@ namespace Server.Tests [InlineData("this is a valid string", "default value", "this is a valid string")] public void TestIsNullOrDefault(string value, string defaultValue, string expected) { - var actual = value.IsNullOrDefault(defaultValue); + var actual = value.DefaultIfNullOrEmpty(defaultValue); Assert.Equal(expected, actual); } diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 60c092fed..8529aaa53 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -124,7 +124,7 @@ namespace Server } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string IsNullOrDefault(this string value, string def) => value?.Length > 0 ? value : def; + public static string DefaultIfNullOrEmpty(this string value, string def) => value?.Length > 0 ? value : def; public static IPAddress Intern(IPAddress ipAddress) { diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index 73fa30833..7a60118f1 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -120,7 +120,7 @@ namespace Server.Commands return "null"; } - ip = ip.Trim().IsNullOrDefault("empty"); + ip = ip.Trim().DefaultIfNullOrEmpty("empty"); var isSafe = true; diff --git a/Projects/UOContent/Engines/Chat/Channel.cs b/Projects/UOContent/Engines/Chat/Channel.cs index 5d8a22e61..7bf8c5c5d 100644 --- a/Projects/UOContent/Engines/Chat/Channel.cs +++ b/Projects/UOContent/Engines/Chat/Channel.cs @@ -39,7 +39,7 @@ namespace Server.Engines.Chat public string Password { get => m_Password; - set => m_Password = value?.Trim().IsNullOrDefault(null); + set => m_Password = (value?.Trim()).DefaultIfNullOrEmpty(null); } public bool VoiceRestricted diff --git a/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs b/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs index 06b1887d2..c2d556efa 100644 --- a/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs +++ b/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs @@ -204,7 +204,7 @@ namespace Server.Engines.Chat } } - password = password?.Trim().IsNullOrDefault(null); + password = (password?.Trim()).DefaultIfNullOrEmpty(null); var joined = Channel.FindChannelByName(name); @@ -246,7 +246,7 @@ namespace Server.Engines.Chat name = param; } - password = password?.Trim().IsNullOrDefault(null); + password = (password?.Trim()).DefaultIfNullOrEmpty(null); Channel.AddChannel(name, password).AddUser(from, password); } diff --git a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs index dd796fe41..de58ce944 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs @@ -262,7 +262,7 @@ namespace Server.Engines.ConPVP if (m_Counter >= m_Hill.ScoreInterval) { - var hill = m_Hill.Name.IsNullOrDefault("the hill"); + var hill = m_Hill.Name.DefaultIfNullOrEmpty("the hill"); var king = m_Hill.King.Name ?? ""; m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill); diff --git a/Projects/UOContent/Gumps/BanDurationGump.cs b/Projects/UOContent/Gumps/BanDurationGump.cs index 0077a4a62..edec1f4c2 100644 --- a/Projects/UOContent/Gumps/BanDurationGump.cs +++ b/Projects/UOContent/Gumps/BanDurationGump.cs @@ -223,7 +223,7 @@ namespace Server.Gumps if (shouldSet) { - var comment = c?.Text.Trim().IsNullOrDefault(null); + var comment = c?.Text.Trim().DefaultIfNullOrEmpty(null); for (var i = 0; i < m_List.Count; ++i) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildGump.cs b/Projects/UOContent/Gumps/Guilds/GuildGump.cs index 59e8b3c4b..cfbe72cb1 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildGump.cs @@ -26,7 +26,7 @@ namespace Server.Gumps if (leader != null) { var leadTitle = leader.GuildTitle?.Trim(); - var leadName = leader.Name?.Trim().IsNullOrDefault("(empty)"); + var leadName = (leader.Name?.Trim()).DefaultIfNullOrEmpty("(empty)"); var text = leadTitle?.Length > 0 ? $"{leadTitle}: {leadName}" : leadName; AddHtml(220, 15, 250, 35, text); @@ -44,7 +44,7 @@ namespace Server.Gumps fealty ??= beholder; - var fealtyName = fealty.Name?.Trim().IsNullOrDefault("(empty)"); + var fealtyName = (fealty.Name?.Trim()).DefaultIfNullOrEmpty("(empty)"); if (beholder == fealty) { diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs index 81fcb2509..2315edd33 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -60,7 +60,7 @@ namespace Server.Guilds AddImageTiled(65, 196, 480, 4, 0x238D); - var s = guild.Charter.IsNullOrDefault("The guild leader has not yet set the guild charter."); + var s = guild.Charter.DefaultIfNullOrEmpty("The guild leader has not yet set the guild charter."); AddHtml(65, 216, 480, 80, s, true, true); if (isLeader) @@ -68,7 +68,7 @@ namespace Server.Guilds AddButton(40, 251, 0x4B9, 0x4BA, 4); // Charter Edit button } - s = guild.Website.IsNullOrDefault("Guild website not yet set."); + s = guild.Website.DefaultIfNullOrEmpty("Guild website not yet set."); AddHtml(65, 306, 480, 30, s, true); if (isLeader) diff --git a/Projects/UOContent/Gumps/HouseGumpAOS.cs b/Projects/UOContent/Gumps/HouseGumpAOS.cs index 2b9ce8c9c..adf139346 100644 --- a/Projects/UOContent/Gumps/HouseGumpAOS.cs +++ b/Projects/UOContent/Gumps/HouseGumpAOS.cs @@ -569,7 +569,7 @@ namespace Server.Gumps { var m = m_House.Owner; - return m?.Deleted != false ? "(unowned)" : m.Name.Trim().IsNullOrDefault("(no name)"); + return m?.Deleted != false ? "(unowned)" : m.Name.Trim().DefaultIfNullOrEmpty("(no name)"); } private string GetDateTime(DateTime val) => diff --git a/Projects/UOContent/Gumps/WhoGump.cs b/Projects/UOContent/Gumps/WhoGump.cs index daff5f958..b405affa4 100644 --- a/Projects/UOContent/Gumps/WhoGump.cs +++ b/Projects/UOContent/Gumps/WhoGump.cs @@ -93,7 +93,7 @@ namespace Server.Gumps public static List BuildList(Mobile owner, string rawFilter) { - var filter = rawFilter.Trim().ToLower().IsNullOrDefault(null); + var filter = rawFilter.Trim().ToLower().DefaultIfNullOrEmpty(null); var list = new List(); var states = TcpServer.Instances; diff --git a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs index ffeed4382..e5404814a 100644 --- a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs +++ b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs @@ -439,7 +439,7 @@ namespace Server.Items AddHtml(255, 180, 150, 20, message.Time.ToString("yyyy-MM-dd HH:mm:ss")); var poster = message.Poster; - var name = poster?.Name?.Trim().IsNullOrDefault("Someone"); + var name = (poster?.Name?.Trim()).DefaultIfNullOrEmpty("Someone"); AddHtml(255, 200, 150, 20, name); diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs index d723710ea..0224ebaa3 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs @@ -182,7 +182,7 @@ namespace Server.Items { var sign = m_House.Sign; - m_Description = sign?.Name?.Trim().IsNullOrDefault("an unnamed house"); + m_Description = (sign?.Name?.Trim()).DefaultIfNullOrEmpty("an unnamed house"); setDesc = true; @@ -257,7 +257,7 @@ namespace Server.Items { if (m_Marked) { - var desc = m_Description?.Trim().IsNullOrDefault("an unknown location"); + var desc = (m_Description?.Trim()).DefaultIfNullOrEmpty("an unknown location"); if (m_TargetMap == Map.Tokuno) { diff --git a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs index 1db34f331..1d518b42a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs @@ -416,7 +416,7 @@ namespace Server.Items from.Send(new PlaySound(0x42, GetWorldLocation())); - from.SendMessage(rune.Description?.Trim().IsNullOrDefault("(indescript)")); + from.SendMessage((rune.Description?.Trim()).DefaultIfNullOrEmpty("(indescript)")); return true; } diff --git a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs index f589a1058..e6f638a6a 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs @@ -89,7 +89,7 @@ namespace Server.Items { list.Add( 1054131, - $"{m_Charges}\t{PetName.IsNullOrDefault(" ")}" + $"{m_Charges}\t{PetName.DefaultIfNullOrEmpty(" ")}" ); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~] } @@ -98,7 +98,7 @@ namespace Server.Items LabelTo( from, 1054131, - $"{m_Charges}\t{PetName.IsNullOrDefault(" ")}" + $"{m_Charges}\t{PetName.DefaultIfNullOrEmpty(" ")}" ); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~] } diff --git a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs index 172d21d29..647925585 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs @@ -93,7 +93,7 @@ namespace Server.Items { list.Add( 1054000, - $"{m_Charges}\t{m_Inscription.IsNullOrDefault(" ")}" + $"{m_Charges}\t{m_Inscription.DefaultIfNullOrEmpty(" ")}" ); // a bracelet of binding : ~1_val~ ~2_val~ } @@ -102,7 +102,7 @@ namespace Server.Items LabelTo( from, 1054000, - $"{m_Charges}\t{m_Inscription.IsNullOrDefault(" ")}" + $"{m_Charges}\t{m_Inscription.DefaultIfNullOrEmpty(" ")}" ); // a bracelet of binding : ~1_val~ ~2_val~ } diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs index 0310e8a6d..cebb4bbe2 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs @@ -966,7 +966,7 @@ namespace Server.Mobiles return; } - var name = item.Name.IsNullOrDefault($"#{item.LabelNumber}"); + var name = item.Name.DefaultIfNullOrEmpty($"#{item.LabelNumber}"); from.SendLocalizedMessage(1043303, name); // Type in a price and description for ~1_ITEM~ (ESC=not for sale) from.Prompt = new VendorPricePrompt(this, vi); diff --git a/Projects/UOContent/Multis/Boats/BaseBoat.cs b/Projects/UOContent/Multis/Boats/BaseBoat.cs index 1d5ace8c1..4cc345ba1 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoat.cs @@ -696,7 +696,7 @@ namespace Server.Multis return; } - Rename(newName.Trim().IsNullOrDefault(null)); + Rename(newName.Trim().DefaultIfNullOrEmpty(null)); } public DryDockResult CheckDryDock(Mobile from) @@ -859,7 +859,7 @@ namespace Server.Multis if (e.Speech.Length > 8) { - Rename(e.Speech.Substring(8).Trim().IsNullOrDefault(null)); + Rename(e.Speech.Substring(8).Trim().DefaultIfNullOrEmpty(null)); } }