use type keyword for String
This commit is contained in:
@@ -10,7 +10,7 @@ public static class RavenQueryableExtensions
|
||||
{
|
||||
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string path, bool isDescending, OrderingType type = OrderingType.String)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(path))
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
char[] a = path.ToCharArray();
|
||||
a[0] = char.ToUpper(a[0]);
|
||||
@@ -27,7 +27,7 @@ public static class RavenQueryableExtensions
|
||||
|
||||
public static IOrderedQueryable<T> ThenBy<T>(this IOrderedQueryable<T> source, string path, bool isDescending, OrderingType type = OrderingType.String)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(path))
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
char[] a = path.ToCharArray();
|
||||
a[0] = char.ToUpper(a[0]);
|
||||
@@ -88,7 +88,7 @@ public static class RavenQueryableExtensions
|
||||
|
||||
public static IQueryable<T> SearchIf<T>(this IQueryable<T> source, Expression<Func<T, object>> fieldSelector, string searchTerms, string suffix = null, string prefix = null, SearchOperator @operator = SearchOperator.Or)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(searchTerms))
|
||||
if (string.IsNullOrWhiteSpace(searchTerms))
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class RavenOptions
|
||||
|
||||
public string Database { get; set; }
|
||||
|
||||
public string CollectionPrefix { get; set; } = String.Empty;
|
||||
public string CollectionPrefix { get; set; } = string.Empty;
|
||||
|
||||
public int CacheInMinutes { get; set; } = 60;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public static class Rfc6238AuthenticationService
|
||||
|
||||
private static byte[] ApplyModifier(byte[] input, string modifier)
|
||||
{
|
||||
if (String.IsNullOrEmpty(modifier))
|
||||
if (string.IsNullOrEmpty(modifier))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ public static class NumberExtensions
|
||||
sizeInBytes = sizeInBytes / power;
|
||||
}
|
||||
|
||||
return String.Format("{0:0.##} {1}", sizeInBytes, units[order]);
|
||||
return string.Format("{0:0.##} {1}", sizeInBytes, units[order]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public static class StringExtensions
|
||||
|
||||
public static string FullTrim(this string value)
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@@ -59,14 +59,14 @@ public static class StringExtensions
|
||||
|
||||
public static string Or(this string value, string fallback)
|
||||
{
|
||||
return String.IsNullOrWhiteSpace(value) ? fallback : value;
|
||||
return string.IsNullOrWhiteSpace(value) ? fallback : value;
|
||||
}
|
||||
|
||||
|
||||
public static string TrimEnd(this string value, string forRemoving)
|
||||
{
|
||||
if (String.IsNullOrEmpty(value)) return value;
|
||||
if (String.IsNullOrEmpty(forRemoving)) return value;
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
if (string.IsNullOrEmpty(forRemoving)) return value;
|
||||
|
||||
while (value.EndsWith(forRemoving, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
@@ -78,8 +78,8 @@ public static class StringExtensions
|
||||
|
||||
public static string TrimStart(this string value, string forRemoving)
|
||||
{
|
||||
if (String.IsNullOrEmpty(value)) return value;
|
||||
if (String.IsNullOrEmpty(forRemoving)) return value;
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
if (string.IsNullOrEmpty(forRemoving)) return value;
|
||||
|
||||
while (value.StartsWith(forRemoving, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
@@ -91,42 +91,42 @@ public static class StringExtensions
|
||||
|
||||
public static bool HasValue(this string input)
|
||||
{
|
||||
return !String.IsNullOrWhiteSpace(input);
|
||||
return !string.IsNullOrWhiteSpace(input);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsNullOrEmpty(this string input)
|
||||
{
|
||||
return String.IsNullOrEmpty(input);
|
||||
return string.IsNullOrEmpty(input);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsNullOrWhiteSpace(this string input)
|
||||
{
|
||||
return String.IsNullOrWhiteSpace(input);
|
||||
return string.IsNullOrWhiteSpace(input);
|
||||
}
|
||||
|
||||
public static string ToCamelCase(this string input)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(input) && input.Length > 1)
|
||||
if (!string.IsNullOrEmpty(input) && input.Length > 1)
|
||||
{
|
||||
return Char.ToLowerInvariant(input[0]) + input.Substring(1);
|
||||
return char.ToLowerInvariant(input[0]) + input.Substring(1);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public static string ToPascalCase(this string input)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(input) && input.Length > 1)
|
||||
if (!string.IsNullOrEmpty(input) && input.Length > 1)
|
||||
{
|
||||
return Char.ToUpperInvariant(input[0]) + input.Substring(1);
|
||||
return char.ToUpperInvariant(input[0]) + input.Substring(1);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public static string ToCamelCaseId(this string input)
|
||||
{
|
||||
if (String.IsNullOrEmpty(input))
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -138,13 +138,13 @@ public static class StringExtensions
|
||||
|
||||
string[] parts = input.Split('.');
|
||||
|
||||
return String.Join(".", parts.Select(x => x.ToCamelCase()));
|
||||
return string.Join(".", parts.Select(x => x.ToCamelCase()));
|
||||
}
|
||||
|
||||
|
||||
public static string ToPascalCaseId(this string input)
|
||||
{
|
||||
if (String.IsNullOrEmpty(input))
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -156,18 +156,18 @@ public static class StringExtensions
|
||||
|
||||
string[] parts = input.Split('.');
|
||||
|
||||
return String.Join(".", parts.Select(x => x.ToPascalCase()));
|
||||
return string.Join(".", parts.Select(x => x.ToPascalCase()));
|
||||
}
|
||||
|
||||
|
||||
public static string RemoveNewLines(this string input)
|
||||
{
|
||||
if (String.IsNullOrEmpty(input))
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
return newLineCharsRegex.Replace(input, String.Empty).Trim();
|
||||
return newLineCharsRegex.Replace(input, string.Empty).Trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public static class StringExtensions
|
||||
throw new ArgumentOutOfRangeException("maxLength", "Has to be at least 4 characters long");
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(input) || input.Length <= maxLength)
|
||||
if (string.IsNullOrEmpty(input) || input.Length <= maxLength)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class Paths : IPaths
|
||||
/// </summary>
|
||||
public string ToFilename(string value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(value))
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class WebRootFileSystem : PhysicalFileSystem, IWebRootFileSystem
|
||||
|
||||
public WebRootFileSystem(string root, string publicPathPrefix) : base(root)
|
||||
{
|
||||
PublicPathPrefix = (publicPathPrefix ?? String.Empty).EnsureEndsWith('/');
|
||||
PublicPathPrefix = (publicPathPrefix ?? string.Empty).EnsureEndsWith('/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,6 +79,6 @@ public class PhysicalFileProvider : IImageProvider
|
||||
List<string> parts = path.Split('/').ToList();
|
||||
|
||||
parts.RemoveAt(parts.Count - 2);
|
||||
return String.Join('/', parts);
|
||||
return string.Join('/', parts);
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,12 @@ public static class MediaExtensions
|
||||
|
||||
public static string CssObjectPosition(this MediaFocalPoint focalPoint)
|
||||
{
|
||||
string values = String.Empty;
|
||||
string values = string.Empty;
|
||||
|
||||
if (focalPoint != null && (focalPoint.Left != 0.5m || focalPoint.Top != 0.5m))
|
||||
{
|
||||
Func<decimal, string> round = input => Decimal.Round(input, 0, MidpointRounding.ToEven).ToString();
|
||||
values = String.Format("{0}% {1}%", round(focalPoint.Left * 100), round(focalPoint.Top * 100));
|
||||
Func<decimal, string> round = input => decimal.Round(input, 0, MidpointRounding.ToEven).ToString();
|
||||
values = string.Format("{0}% {1}%", round(focalPoint.Left * 100), round(focalPoint.Top * 100));
|
||||
}
|
||||
|
||||
return values;
|
||||
@@ -40,7 +40,7 @@ public static class MediaExtensions
|
||||
{
|
||||
if (path.IsNullOrEmpty())
|
||||
{
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
List<string> parts = path.Split('/').ToList();
|
||||
@@ -48,33 +48,33 @@ public static class MediaExtensions
|
||||
|
||||
if (parts[0] == "http:" || parts[0] == "https:")
|
||||
{
|
||||
return String.Join('/', parts);
|
||||
return string.Join('/', parts);
|
||||
}
|
||||
|
||||
if (isFinchMedia)
|
||||
{
|
||||
// TODO this is bullshit because we need to get the base path from options
|
||||
return parts[1] == "media" || parts[0] == "media"
|
||||
? String.Join('/', parts)
|
||||
: ("/media" + String.Join('/', parts).EnsureStartsWith('/'));
|
||||
? string.Join('/', parts)
|
||||
: ("/media" + string.Join('/', parts).EnsureStartsWith('/'));
|
||||
}
|
||||
|
||||
return String.Join('/', parts).EnsureStartsWith('/');
|
||||
return string.Join('/', parts).EnsureStartsWith('/');
|
||||
}
|
||||
|
||||
|
||||
static string StringifyFocalPoint(MediaFocalPoint focalPoint = null)
|
||||
{
|
||||
string xy = String.Empty;
|
||||
string xy = string.Empty;
|
||||
|
||||
if (focalPoint != null && (focalPoint.Left != 0.5m || focalPoint.Top != 0.5m))
|
||||
{
|
||||
Func<decimal, string> round = input =>
|
||||
{
|
||||
return Decimal.Round(input, 2, MidpointRounding.ToEven).ToString().Replace(',', '.');
|
||||
return decimal.Round(input, 2, MidpointRounding.ToEven).ToString().Replace(',', '.');
|
||||
};
|
||||
|
||||
xy = String.Format(":{0},{1}", round(focalPoint.Left), round(focalPoint.Top));
|
||||
xy = string.Format(":{0},{1}", round(focalPoint.Left), round(focalPoint.Top));
|
||||
}
|
||||
|
||||
return xy;
|
||||
|
||||
@@ -7,7 +7,7 @@ public class MediaFileSystem : PhysicalFileSystem, IMediaFileSystem
|
||||
|
||||
public MediaFileSystem(string root, string publicPathPrefix) : base(root)
|
||||
{
|
||||
PublicPathPrefix = (publicPathPrefix ?? String.Empty).EnsureEndsWith('/');
|
||||
PublicPathPrefix = (publicPathPrefix ?? string.Empty).EnsureEndsWith('/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MetadataService : IMetadataService
|
||||
// generate robots
|
||||
bool noIndex = options.NoIndex ?? false;
|
||||
bool noFollow = options.NoFollow ?? false;
|
||||
model.Robots = String.Format("{0},{1}", noIndex ? "noindex" : "index", noFollow ? "nofollow" : "follow");
|
||||
model.Robots = string.Format("{0},{1}", noIndex ? "noindex" : "index", noFollow ? "nofollow" : "follow");
|
||||
|
||||
// title
|
||||
HashSet<string> fragments = options.TitleFragments.Where(x => !x.IsNullOrWhiteSpace()).Reverse().ToHashSet();
|
||||
|
||||
@@ -144,7 +144,7 @@ public class Numbers : INumbers
|
||||
string original = match.Value;
|
||||
string type = match.Groups[1].Value;
|
||||
string options = match.Groups[2].Value;
|
||||
string result = String.Empty;
|
||||
string result = string.Empty;
|
||||
|
||||
if (type == "year")
|
||||
{
|
||||
@@ -161,11 +161,11 @@ public class Numbers : INumbers
|
||||
else if (type == "random")
|
||||
{
|
||||
int length = 5;
|
||||
if (!options.IsNullOrWhiteSpace() && Int32.TryParse(options, out int oLength) && oLength > 0 && oLength <= 10)
|
||||
if (!options.IsNullOrWhiteSpace() && int.TryParse(options, out int oLength) && oLength > 0 && oLength <= 10)
|
||||
{
|
||||
length = oLength;
|
||||
}
|
||||
result = random.Next(0, Int32.MaxValue).ToString("D10").Substring(0, length);
|
||||
result = random.Next(0, int.MaxValue).ToString("D10").Substring(0, length);
|
||||
}
|
||||
|
||||
output = output.ReplaceFirst(original, result);
|
||||
|
||||
@@ -245,7 +245,7 @@ public class RazorRenderer : IRazorRenderer, IDisposable
|
||||
}
|
||||
|
||||
IEnumerable<string> searchedLocations = getViewResult.SearchedLocations.Concat(findViewResult.SearchedLocations);
|
||||
string errorMessage = String.Join(Environment.NewLine, new[] { $"Unable to find view '{viewName}'. The following locations were searched:" }.Concat(searchedLocations));
|
||||
string errorMessage = string.Join(Environment.NewLine, new[] { $"Unable to find view '{viewName}'. The following locations were searched:" }.Concat(searchedLocations));
|
||||
|
||||
throw new InvalidOperationException(errorMessage);
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public class RazorRenderer : IRazorRenderer, IDisposable
|
||||
}
|
||||
|
||||
IEnumerable<string> searchedLocations = getPageResult.SearchedLocations.Concat(findPageResult.SearchedLocations);
|
||||
string errorMessage = String.Join(Environment.NewLine, new[] { $"Unable to find page '{pageName}'. The following locations were searched:" }.Concat(searchedLocations));
|
||||
string errorMessage = string.Join(Environment.NewLine, new[] { $"Unable to find page '{pageName}'. The following locations were searched:" }.Concat(searchedLocations));
|
||||
|
||||
throw new InvalidOperationException(errorMessage);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RequestUrlResolver : IRequestUrlResolver
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(path))
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class RequestUrlResolver : IRequestUrlResolver
|
||||
return null;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(path))
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
return GetRoot();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class RequestUrlResolver : IRequestUrlResolver
|
||||
}
|
||||
|
||||
HttpRequest request = HttpContextAccessor.HttpContext.Request;
|
||||
return $"{request.Scheme}://{request.Host.Host}{GetPortUrlPart(request)}{(includePath ? request.PathBase.ToUriComponent() : String.Empty)}";
|
||||
return $"{request.Scheme}://{request.Host.Host}{GetPortUrlPart(request)}{(includePath ? request.PathBase.ToUriComponent() : string.Empty)}";
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class RequestUrlResolver : IRequestUrlResolver
|
||||
{
|
||||
if (!request.Host.Port.HasValue || request.Host.Port == 80 || (request.Host.Port == 443 && request.IsHttps))
|
||||
{
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return ":" + request.Host.Port;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class IdGenerator
|
||||
/// </summary>
|
||||
public static string HashString(string value)
|
||||
{
|
||||
return GetStableHashCode(value).ToString().Replace("-", String.Empty);
|
||||
return GetStableHashCode(value).ToString().Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class IdGenerator
|
||||
/// </summary>
|
||||
public static string HashObject(params object[] values)
|
||||
{
|
||||
return GetStableHashCode(JsonSerializer.Serialize(values)).ToString().Replace("-", String.Empty);
|
||||
return GetStableHashCode(JsonSerializer.Serialize(values)).ToString().Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,10 +79,10 @@ public class ObjectCopycat
|
||||
|
||||
private static string CombineKey(string sep, string key1, string key2)
|
||||
{
|
||||
if (String.IsNullOrEmpty(key1))
|
||||
if (string.IsNullOrEmpty(key1))
|
||||
{
|
||||
return key2;
|
||||
}
|
||||
return String.Join(sep, key1, key2);
|
||||
return string.Join(sep, key1, key2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ObjectTraverser
|
||||
HashSet<object> exploredObjects = new HashSet<object>();
|
||||
List<Result<T>> found = new List<Result<T>>();
|
||||
|
||||
Find<T>(value, null, String.Empty, null, exploredObjects, found);
|
||||
Find<T>(value, null, string.Empty, null, exploredObjects, found);
|
||||
|
||||
return found;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ObjectTraverser
|
||||
HashSet<object> exploredObjects = new HashSet<object>();
|
||||
List<Result> found = new List<Result>();
|
||||
|
||||
Find(type, value, null, String.Empty, null, exploredObjects, found);
|
||||
Find(type, value, null, string.Empty, null, exploredObjects, found);
|
||||
|
||||
return found;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class ObjectTraverser
|
||||
HashSet<string> exploredObjects = new HashSet<string>();
|
||||
List<Result<T>> found = new List<Result<T>>();
|
||||
|
||||
FindAttribute<T>(value, null, String.Empty, null, exploredObjects, found);
|
||||
FindAttribute<T>(value, null, string.Empty, null, exploredObjects, found);
|
||||
|
||||
return found;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ObjectTraverser
|
||||
int idx = 0;
|
||||
foreach (object item in enumerable)
|
||||
{
|
||||
Find<T>(item, value, CombineKey(String.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), property, exploredObjects, found);
|
||||
Find<T>(item, value, CombineKey(string.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), property, exploredObjects, found);
|
||||
idx += 1;
|
||||
}
|
||||
return;
|
||||
@@ -135,7 +135,7 @@ public class ObjectTraverser
|
||||
int idx = 0;
|
||||
foreach (object item in enumerable)
|
||||
{
|
||||
Find(type, item, value, CombineKey(String.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), property, exploredObjects, found);
|
||||
Find(type, item, value, CombineKey(string.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), property, exploredObjects, found);
|
||||
idx += 1;
|
||||
}
|
||||
return;
|
||||
@@ -213,7 +213,7 @@ public class ObjectTraverser
|
||||
int idx = 0;
|
||||
foreach (object item in enumerable)
|
||||
{
|
||||
FindAttribute<T>(item, value, CombineKey(String.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), null, exploredObjects, found);
|
||||
FindAttribute<T>(item, value, CombineKey(string.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), null, exploredObjects, found);
|
||||
idx += 1;
|
||||
}
|
||||
return;
|
||||
@@ -237,11 +237,11 @@ public class ObjectTraverser
|
||||
|
||||
private static string CombineKey(string sep, string key1, string key2)
|
||||
{
|
||||
if (String.IsNullOrEmpty(key1))
|
||||
if (string.IsNullOrEmpty(key1))
|
||||
{
|
||||
return key2;
|
||||
}
|
||||
return String.Join(sep, key1, key2);
|
||||
return string.Join(sep, key1, key2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ public class Safenames
|
||||
/// </summary>
|
||||
static string Generate(string value, Scope scope)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(value))
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
char previous = default;
|
||||
|
||||
Reference in New Issue
Block a user