Fixes string interpolation

This commit is contained in:
Kamron Batman 2018-09-14 13:07:43 -07:00
parent 42d0b6271f
commit 7d3a0ca265
233 changed files with 758 additions and 690 deletions

View file

@ -152,7 +152,7 @@ namespace Server.Misc
private static string FormatDirectory( string root, string name, string timeStamp )
{
return Path.Combine( root, String.Format( "{0} ({1})", name, timeStamp ) );
return Path.Combine( root, $"{name} ({timeStamp})");
}
private static string FindTimeStamp( string input )
@ -174,14 +174,7 @@ namespace Server.Misc
{
DateTime now = DateTime.UtcNow;
return String.Format( "{0}-{1}-{2} {3}-{4:D2}-{5:D2}",
now.Day,
now.Month,
now.Year,
now.Hour,
now.Minute,
now.Second
);
return $"{now.Day}-{now.Month}-{now.Year} {now.Hour}-{now.Minute:D2}-{now.Second:D2}";
}
}
}

View file

@ -266,7 +266,7 @@ namespace Server
m_Stream.Fill( 2 );
//m_Stream.WriteLittleUniNull( "\t#1018280" );
m_Stream.WriteLittleUniNull( String.Format( "\t{0}", args.ToString() ) );
m_Stream.WriteLittleUniNull($"\t{args.ToString()}");
m_Stream.Write( (short)0x1 ); //Even more Unknown -> Possibly something saying 'hey, I have more data!'?
m_Stream.Fill( 2 );

View file

@ -100,7 +100,7 @@ namespace Server.Misc
if ( Required != null && version < Required && ( m_OldClientResponse == OldClientResponse.Kick ||( m_OldClientResponse == OldClientResponse.LenientKick && (DateTime.UtcNow - state.Mobile.CreationTime) > m_AgeLeniency && state.Mobile is PlayerMobile mobile && mobile.GameTime > m_GameTimeLeniency )))
{
kickMessage = String.Format( "This server requires your client version be at least {0}.", Required );
kickMessage = $"This server requires your client version be at least {Required}.";
}
else if ( !AllowGod || !AllowRegular || !AllowUOTD )
{
@ -168,7 +168,8 @@ namespace Server.Misc
{
if ( m.NetState != null && m.NetState.Version < Required )
{
Gump g = new WarningGump( 1060637, 30720, String.Format( "Your client is out of date. Please update your client.<br>This server recommends that your client version be at least {0}.<br> <br>You are currently using version {1}.<br> <br>To patch, run UOPatch.exe inside your Ultima Online folder.", Required, m.NetState.Version ), 0xFFC000, 480, 360,
Gump g = new WarningGump( 1060637, 30720,
$"Your client is out of date. Please update your client.<br>This server recommends that your client version be at least {Required}.<br> <br>You are currently using version {m.NetState.Version}.<br> <br>To patch, run UOPatch.exe inside your Ultima Online folder.", 0xFFC000, 480, 360,
delegate( Mobile mob, bool selection, object o )
{
m.SendMessage( "You will be reminded of this again." );

View file

@ -130,7 +130,7 @@ namespace Server.Misc
string timeStamp = GetTimeStamp();
string root = GetRoot();
string rootBackup = Combine( root, String.Format( "Backups/Crashed/{0}/", timeStamp ) );
string rootBackup = Combine( root, $"Backups/Crashed/{timeStamp}/");
string rootOrigin = Combine( root, String.Format( "Saves/" ) );
// Create new directories
@ -173,7 +173,7 @@ namespace Server.Misc
try
{
string timeStamp = GetTimeStamp();
string fileName = String.Format( "Crash {0}.log", timeStamp );
string fileName = $"Crash {timeStamp}.log";
string root = GetRoot();
string filePath = Combine( root, fileName );
@ -246,14 +246,7 @@ namespace Server.Misc
{
DateTime now = DateTime.UtcNow;
return String.Format( "{0}-{1}-{2}-{3}-{4}-{5}",
now.Day,
now.Month,
now.Year,
now.Hour,
now.Minute,
now.Second
);
return $"{now.Day}-{now.Month}-{now.Year}-{now.Hour}-{now.Minute}-{now.Second}";
}
}
}

View file

@ -63,7 +63,7 @@ namespace Server.Misc
// .NET relies on the MTA to generate Message-ID header. Not all MTAs will add this header.
DateTime now = DateTime.UtcNow;
string messageID = String.Format("<{0}.{1}@{2}>", now.ToString("yyyyMMdd"), now.ToString("HHmmssff"), EmailServer );
string messageID = $"<{now.ToString("yyyyMMdd")}.{now.ToString("HHmmssff")}@{EmailServer}>";
message.Headers.Add("Message-ID", messageID );
message.Headers.Add("X-Mailer", "RunUO");

View file

@ -28,7 +28,7 @@ namespace Server
{
m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(
assemblyName,
String.Format( "{0}.dll", assemblyName.ToLower() ),
$"{assemblyName.ToLower()}.dll",
false
);
}
@ -49,7 +49,7 @@ namespace Server
public void Save()
{
m_AssemblyBuilder.Save(
String.Format( "{0}.dll", m_AssemblyName.ToLower() )
$"{m_AssemblyName.ToLower()}.dll"
);
}
}

View file

@ -60,14 +60,16 @@ namespace Server.Misc
if ( m_HasLocalInfo )
{
s = String.Format( "{0}‎ - {1}", DefaultLocalNames ? m_Language_LocalName : m_Language, DefaultLocalNames ? m_Country_LocalName : m_Country );
s =
$"{(DefaultLocalNames ? m_Language_LocalName : m_Language)}‎ - {(DefaultLocalNames ? m_Country_LocalName : m_Country)}";
if ( ShowAlternatives )
s += String.Format( "‎ 【{0}‎ - {1}‎】", DefaultLocalNames ? m_Language : m_Language_LocalName, DefaultLocalNames ? m_Country : m_Country_LocalName );
s +=
$"‎ 【{(DefaultLocalNames ? m_Language : m_Language_LocalName)}‎ - {(DefaultLocalNames ? m_Country : m_Country_LocalName)}‎】";
}
else
{
s = String.Format( "{0}‎ - {1}", m_Language, m_Country );
s = $"{m_Language}‎ - {m_Country}";
}
return s;
@ -216,17 +218,17 @@ namespace Server.Misc
private static string GetFormattedInfo( string code )
{
if ( code == null || code.Length != 3 )
return String.Format( "Unknown code {0}", code );
return $"Unknown code {code}";
for ( int i = 0; i < InternationalCodes.Length; i++ )
{
if ( code == InternationalCodes[i].Code )
{
return String.Format( "{0}", InternationalCodes[i].GetName() );
return $"{InternationalCodes[i].GetName()}";
}
}
return String.Format( "Unknown code {0}", code );
return $"Unknown code {code}";
}
private static bool DefaultLocalNames = false;
@ -296,7 +298,8 @@ namespace Server.Misc
}
}
writer.WriteLine( String.Format( "Language statistics. Numbers show how many {0} use the specified language.", CountAccounts ? "accounts" : "playermobile" ) );
writer.WriteLine(
$"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language.");
writer.WriteLine( "====================================================================================================" );
writer.WriteLine();
@ -305,7 +308,7 @@ namespace Server.Misc
list.Sort( InternationalCodeComparer.Instance );
foreach ( InternationalCodeCounter c in list )
writer.WriteLine( String.Format( "{0}‎ : {1}", GetFormattedInfo( c.Code ), c.Count ) );
writer.WriteLine($"{GetFormattedInfo(c.Code)}‎ : {c.Count}");
e.Mobile.SendMessage( "Languages list generated." );
}

View file

@ -98,7 +98,7 @@ namespace Server
"* You feel yourself resisting the effects of the poison *" );
m_Mobile.NonlocalOverheadMessage( MessageType.Emote, 0x3F, true,
String.Format( "* {0} seems resistant to the poison *", m_Mobile.Name ) );
$"* {m_Mobile.Name} seems resistant to the poison *");
Stop();
return;

View file

@ -35,7 +35,7 @@ namespace Server.Misc
}
}
from.SendLocalizedMessage( 1072623, String.Format( "{0}\t{1}", targ.Name, name ) ); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
from.SendLocalizedMessage( 1072623, $"{targ.Name}\t{name}"); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
}
targ.Name = name;

View file

@ -414,12 +414,12 @@ namespace Server.Misc
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
return $"<CENTER>{text}</CENTER>";
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private const int LabelColor32 = 0xFFFFFF;
@ -468,7 +468,7 @@ namespace Server.Misc
if ( editing )
{
AddHtml( 22, 22, 294, 20, Color( String.Format( "{0} total", totalVotes ), LabelColor32 ), false, false );
AddHtml( 22, 22, 294, 20, Color($"{totalVotes} total", LabelColor32 ), false, false );
AddButton( 287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0 );
}
@ -596,7 +596,7 @@ namespace Server.Misc
if ( m.Groups[1].Success )
{
if ( m.Groups[2].Success )
return String.Format( "<a href=\"{0}\">{1}</a>", m.Groups[1].Value, m.Groups[2].Value );
return $"<a href=\"{m.Groups[1].Value}\">{m.Groups[2].Value}</a>";
}
else if ( m.Groups[2].Success )
{

View file

@ -49,7 +49,7 @@ namespace Server
if ( m_Number > 0 )
return String.Format( "{0} (0x{0:X})", m_Number );
else if ( m_String != null )
return String.Format( "\"{0}\"", m_String );
return $"\"{m_String}\"";
return propsGump ? "-empty-" : "empty";
}
@ -152,7 +152,7 @@ namespace Server
else if ( def.m_String != null )
{
if ( stringColor >= 0 ) // 8 bits per RGB component (24 bit RGB)
g.AddHtml( x, y, width, height, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", stringColor, def.m_String ), back, scroll );
g.AddHtml( x, y, width, height, $"<BASEFONT COLOR=#{stringColor:X6}>{def.m_String}</BASEFONT>", back, scroll );
else
g.AddHtml( x, y, width, height, def.m_String, back, scroll );
}