refactor: replace verbose checks with String.IsNullOrEmpty where applicable.

Thanks to Kira for this patch from http://opensimulator.org/mantis/view.php?id=6845
This commit is contained in:
Justin Clark-Casey (justincc)
2013-11-15 21:45:08 +00:00
parent b4932bda2a
commit 7cab41f422
30 changed files with 46 additions and 47 deletions

View File

@@ -421,7 +421,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
item.CreatorId = ospResolvedId.ToString();
item.CreatorData = string.Empty;
}
else if (item.CreatorData == null || item.CreatorData == String.Empty)
else if (string.IsNullOrEmpty(item.CreatorData))
{
item.CreatorId = m_userInfo.PrincipalID.ToString();
// item.CreatorIdAsUuid = new UUID(item.CreatorId);
@@ -522,7 +522,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
foreach (SceneObjectGroup sog in sceneObjects)
foreach (SceneObjectPart sop in sog.Parts)
if (sop.CreatorData == null || sop.CreatorData == "")
if (string.IsNullOrEmpty(sop.CreatorData))
sop.CreatorID = m_creatorIdForAssetId[assetId];
if (coa != null)

View File

@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
private void AdjustIdentifiers(AssetMetadata meta)
{
if (meta.CreatorID != null && meta.CreatorID != string.Empty)
if (!string.IsNullOrEmpty(meta.CreatorID))
{
UUID uuid = UUID.Zero;
UUID.TryParse(meta.CreatorID, out uuid);

View File

@@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
return userdata.ServerURLs[serverType].ToString();
}
if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
if (!string.IsNullOrEmpty(userdata.HomeURL))
{
//m_log.DebugFormat(
// "[USER MANAGEMENT MODULE]: Did not find url type {0} so requesting urls from '{1}' for {2}",
@@ -552,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
if (oldUser != null)
{
if (creatorData == null || creatorData == String.Empty)
if (string.IsNullOrEmpty(creatorData))
{
//ignore updates without creator data
return;

View File

@@ -460,9 +460,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
Request.Headers.Add(HttpCustomHeaders[i],
HttpCustomHeaders[i+1]);
}
if (proxyurl != null && proxyurl.Length > 0)
if (!string.IsNullOrEmpty(proxyurl))
{
if (proxyexcepts != null && proxyexcepts.Length > 0)
if (!string.IsNullOrEmpty(proxyexcepts))
{
string[] elist = proxyexcepts.Split(';');
Request.Proxy = new WebProxy(proxyurl, true, elist);
@@ -483,7 +483,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
}
// Encode outbound data
if (OutboundBody != null && OutboundBody.Length > 0)
if (!string.IsNullOrEmpty(OutboundBody))
{
byte[] data = Util.UTF8.GetBytes(OutboundBody);

View File

@@ -161,9 +161,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
{
WebRequest request = HttpWebRequest.Create(url);
if (m_proxyurl != null && m_proxyurl.Length > 0)
if (!string.IsNullOrEmpty(m_proxyurl))
{
if (m_proxyexcepts != null && m_proxyexcepts.Length > 0)
if (!string.IsNullOrEmpty(m_proxyexcepts))
{
string[] elist = m_proxyexcepts.Split(';');
request.Proxy = new WebProxy(m_proxyurl, true, elist);

View File

@@ -677,7 +677,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
// if not, use as method name
UUID parseUID;
string mName = "llRemoteData";
if ((Channel != null) && (Channel != ""))
if (!string.IsNullOrEmpty(Channel))
if (!UUID.TryParse(Channel, out parseUID))
mName = Channel;
else

View File

@@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (sp == null)
{
inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI");
if (inventoryURL != null && inventoryURL != string.Empty)
if (!string.IsNullOrEmpty(inventoryURL))
{
inventoryURL = inventoryURL.Trim(new char[] { '/' });
m_InventoryURLs.Add(userID, inventoryURL);

View File

@@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// or creator data is present. Otherwise, use the estate owner instead.
foreach (SceneObjectPart part in sceneObject.Parts)
{
if (part.CreatorData == null || part.CreatorData == string.Empty)
if (string.IsNullOrEmpty(part.CreatorData))
{
if (!ResolveUserUuid(scene, part.CreatorID))
part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
@@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
}
if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
if (string.IsNullOrEmpty(kvp.Value.CreatorData))
{
if (!ResolveUserUuid(scene, kvp.Value.CreatorID))
kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;