Using 'nameof' operator instead of margic strings

This commit is contained in:
Hisham Abdullah Bin Ateya 2015-06-12 02:26:34 +03:00
parent a3c593bda9
commit 1f9a451e2f
3 changed files with 5 additions and 5 deletions

View File

@ -170,11 +170,11 @@ namespace Microsoft.AspNet.Mvc.Routing
// would throw. // would throw.
#if DNX451 #if DNX451
throw new InvalidEnumArgumentException( throw new InvalidEnumArgumentException(
"item", nameof(item),
(int)constraint.KeyHandling, (int)constraint.KeyHandling,
typeof(RouteKeyHandling)); typeof(RouteKeyHandling));
#else #else
throw new ArgumentOutOfRangeException("item"); throw new ArgumentOutOfRangeException(nameof(item));
#endif #endif
} }

View File

@ -29,11 +29,11 @@ namespace Microsoft.AspNet.Mvc
{ {
if (bitLength < 32 || bitLength % 8 != 0) if (bitLength < 32 || bitLength % 8 != 0)
{ {
throw new ArgumentOutOfRangeException("bitLength"); throw new ArgumentOutOfRangeException(nameof(bitLength));
} }
if (data == null || data.Length != bitLength / 8) if (data == null || data.Length != bitLength / 8)
{ {
throw new ArgumentOutOfRangeException("data"); throw new ArgumentOutOfRangeException(nameof(data));
} }
_data = data; _data = data;

View File

@ -1744,7 +1744,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{ {
if (value < DateOfBirth) if (value < DateOfBirth)
{ {
throw new ArgumentOutOfRangeException("value", "Date of death can't be before date of birth."); throw new ArgumentOutOfRangeException(nameof(value), "Date of death can't be before date of birth.");
} }
_dateOfDeath = value; _dateOfDeath = value;
} }