Fixes more casting

This commit is contained in:
Kamron Batman 2018-08-19 11:04:07 +08:00
parent 61937d9c97
commit e77d695684
91 changed files with 512 additions and 908 deletions

View file

@ -90,9 +90,7 @@ namespace Server.Engines.Reports
{
for ( int j = 0; j < ss.Children.Count; ++j )
{
Report report = ss.Children[j] as Report;
if ( report == null || report.Name != reportName )
if ( !(ss.Children[j] is Report report) || report.Name != reportName )
continue;
for ( int k = 0; k < report.Items.Count; ++k )

View file

@ -64,10 +64,10 @@ namespace Server.Engines.Reports
{
PersistableObject child = ip.GetChild();
if ( child is ReportColumn )
m_Columns.Add( (ReportColumn) child );
else if ( child is ReportItem )
m_Items.Add( (ReportItem) child );
if ( child is ReportColumn column )
m_Columns.Add( column );
else if ( child is ReportItem item )
m_Items.Add( item );
}
}
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections;
using Server;
using Server.Accounting;
using Server.Engines;
using Server.Engines.Help;
@ -192,15 +193,7 @@ namespace Server.Engines.Reports
public static string GetAccount( Mobile mob )
{
if ( mob == null )
return null;
Accounting.Account acct = mob.Account as Accounting.Account;
if ( acct == null )
return null;
return acct.Username;
return mob?.Account is Account acct ? acct.Username : null;
}
public PageInfo()

View file

@ -51,12 +51,10 @@ namespace Server.Engines.Reports
{
lock ( RenderLock )
{
if ( account == null || account.Length == 0 )
if ( string.IsNullOrEmpty(account) )
return null;
StaffInfo info = m_StaffInfo[account] as StaffInfo;
if ( info == null )
if ( !(m_StaffInfo[account] is StaffInfo info) )
m_StaffInfo[account] = info = new StaffInfo( account );
return info;
@ -65,12 +63,10 @@ namespace Server.Engines.Reports
public UserInfo GetUserInfo( string account )
{
if ( account == null || account.Length == 0 )
if ( string.IsNullOrEmpty(account) )
return null;
UserInfo info = m_UserInfo[account] as UserInfo;
if ( info == null )
if ( !(m_UserInfo[account] is UserInfo info) )
m_UserInfo[account] = info = new UserInfo( account );
return info;
@ -123,10 +119,8 @@ namespace Server.Engines.Reports
{
PersistableObject obj = ip.GetChild();
if ( obj is PageInfo )
if ( obj is PageInfo pageInfo )
{
PageInfo pageInfo = obj as PageInfo;
pageInfo.UpdateResolver();
if ( pageInfo.TimeSent >= min || pageInfo.TimeResolved >= min )
@ -140,10 +134,8 @@ namespace Server.Engines.Reports
pageInfo.Resolver = null;
}
}
else if ( obj is QueueStatus )
else if ( obj is QueueStatus queueStatus )
{
QueueStatus queueStatus = obj as QueueStatus;
if ( queueStatus.TimeStamp >= min )
m_QueueStats.Add( queueStatus );
}