meh, null check some other bizstring library functions while I'm thinking about it

This commit is contained in:
adelikat 2014-05-21 02:12:27 +00:00
parent ac6c5e6b48
commit af9c462826
1 changed files with 45 additions and 0 deletions

View File

@ -62,6 +62,11 @@ namespace BizHawk.Client.Common
)] )]
public static string Trim(string str) public static string Trim(string str)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.Trim(); return str.Trim();
} }
@ -71,6 +76,11 @@ namespace BizHawk.Client.Common
)] )]
public static string Replace(string str, string str2, string replace) public static string Replace(string str, string str2, string replace)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.Replace(str2, replace); return str.Replace(str2, replace);
} }
@ -80,6 +90,11 @@ namespace BizHawk.Client.Common
)] )]
public static string ToUpper(string str) public static string ToUpper(string str)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.ToUpper(); return str.ToUpper();
} }
@ -89,6 +104,11 @@ namespace BizHawk.Client.Common
)] )]
public static string ToLower(string str) public static string ToLower(string str)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.ToLower(); return str.ToLower();
} }
@ -98,6 +118,11 @@ namespace BizHawk.Client.Common
)] )]
public static string SubString(string str, int position, int length) public static string SubString(string str, int position, int length)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.Substring(position, length); return str.Substring(position, length);
} }
@ -107,6 +132,11 @@ namespace BizHawk.Client.Common
)] )]
public static string Remove(string str, int position, int count) public static string Remove(string str, int position, int count)
{ {
if (string.IsNullOrEmpty(str))
{
return null;
}
return str.Remove(position, count); return str.Remove(position, count);
} }
@ -116,6 +146,11 @@ namespace BizHawk.Client.Common
)] )]
public static bool Contains(string str, string str2) public static bool Contains(string str, string str2)
{ {
if (string.IsNullOrEmpty(str))
{
return false;
}
return str.Contains(str2); return str.Contains(str2);
} }
@ -125,6 +160,11 @@ namespace BizHawk.Client.Common
)] )]
public static bool StartsWith(string str, string str2) public static bool StartsWith(string str, string str2)
{ {
if (string.IsNullOrEmpty(str))
{
return false;
}
return str.StartsWith(str2); return str.StartsWith(str2);
} }
@ -134,6 +174,11 @@ namespace BizHawk.Client.Common
)] )]
public static bool EndsWith(string str, string str2) public static bool EndsWith(string str, string str2)
{ {
if (string.IsNullOrEmpty(str))
{
return false;
}
return str.EndsWith(str2); return str.EndsWith(str2);
} }