Avoid hard-coded parameter names.

This makes it easier to rename the parameter in the future as we don't
have to search for the parameter name within strings.
This commit is contained in:
Kenneth Hsu
2017-09-25 19:54:54 -07:00
parent e9ffc2cbe1
commit b84e7bd34d
7 changed files with 7 additions and 7 deletions
@@ -207,7 +207,7 @@ namespace Duplicati.Library.Compression
public FileArchiveZip(string filename, Dictionary<string, string> options)
{
if (string.IsNullOrEmpty(filename) && filename.Trim().Length == 0)
throw new ArgumentException("Invalid filename.", "filename");
throw new ArgumentException("Invalid filename.", nameof(filename));
if (File.Exists(filename) && new FileInfo(filename).Length > 0)
{
@@ -71,7 +71,7 @@ namespace Duplicati.Library.Encryption
public AESEncryption(string passphrase, Dictionary<string, string> options)
{
if(string.IsNullOrEmpty(passphrase))
throw new ArgumentException(Strings.AESEncryption.EmptyKeyError, "passphrase");
throw new ArgumentException(Strings.AESEncryption.EmptyKeyError, nameof(passphrase));
m_key = passphrase;
@@ -223,7 +223,7 @@ namespace Duplicati.Library.Main.Database
if (filter == null || filter.Empty)
pathprefix = "";
else if (filter as Library.Utility.FilterExpression == null || ((Library.Utility.FilterExpression)filter).Type != Duplicati.Library.Utility.FilterType.Simple || ((Library.Utility.FilterExpression)filter).GetSimpleList().Length != 1)
throw new ArgumentException("Filter for list-folder-contents must be a path prefix with no wildcards", "filter");
throw new ArgumentException("Filter for list-folder-contents must be a path prefix with no wildcards", nameof(filter));
else
pathprefix = ((Library.Utility.FilterExpression)filter).GetSimpleList().First();
@@ -165,7 +165,7 @@ namespace Duplicati.Library.Main.Database
public bool TryGetChild(string name, out FolderEntry v)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentException("Invalid pathname.", "name");
throw new ArgumentException("Invalid pathname.", nameof(name));
if (m_folders == null)
{
@@ -114,7 +114,7 @@ namespace Duplicati.Library.Snapshots
drive = drive.Substring(0, drive.Length - 1);
if (!drive.EndsWith(":"))
throw new ArgumentException("The drive specification must end with a colon.", "drive");
throw new ArgumentException("The drive specification must end with a colon.", nameof(drive));
Win32API.DDD_Flags flags = 0;
if (!notifyShell)
+1 -1
View File
@@ -157,7 +157,7 @@ namespace Duplicati.Library.Utility
: this()
{
if (maxCapacity <= 0)
throw new ArgumentException("maxCapacity must be a positive number", "maxCapacity");
throw new ArgumentException("maxCapacity must be a positive number", nameof(maxCapacity));
m_maxCapacity = maxCapacity;
}
+1 -1
View File
@@ -158,7 +158,7 @@ namespace Duplicati.Library.Utility
catch
{
}
throw new ArgumentException(Strings.Uri.UriParseError(url), "url");
throw new ArgumentException(Strings.Uri.UriParseError(url), nameof(url));
}
this.Scheme = m.Groups["scheme"].Value;