From 498fc2f7938593287350cde7e8b308a90b1a6427 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Tue, 25 Feb 2025 11:31:32 +0100 Subject: [PATCH] remove zero.documentsession --- .../Extensions/RavenQueryableExtensions.cs | 6 +-- .../ZeroDocumentSessionExtensions.cs | 4 +- .../Operations/RavenOperations.Write.cs | 8 ++-- zero.Raven/Operations/RavenOperations.cs | 10 ++--- zero.Raven/RavenOptions.cs | 2 +- .../Tokens/Rfc6238AuthenticationService.cs | 2 +- zero.Raven/Tokens/ZeroTokenProvider.cs | 8 ++-- zero.Raven/Usings.cs | 9 ++++- zero.Raven/ZeroDocumentSession.cs | 32 --------------- zero.Raven/ZeroStore.cs | 28 ++++--------- zero/Extensions/NumberExtensions.cs | 2 +- zero/Extensions/StringExtensions.cs | 40 +++++++++---------- zero/FileStorage/Paths.cs | 2 +- zero/FileStorage/WebRootFileSystem.cs | 2 +- zero/Media/ImageSharp/PhysicalFileProvider.cs | 2 +- zero/Media/MediaExtensions.cs | 22 +++++----- zero/Media/MediaFileSystem.cs | 2 +- zero/Metadata/MetadataService.cs | 2 +- zero/Numbers/Numbers.cs | 6 +-- zero/Rendering/RazorRenderer.cs | 4 +- zero/Routing/RequestUrlResolver.cs | 8 ++-- zero/TagHelpers/ClassTagHelper.cs | 4 +- zero/TagHelpers/StripHtmlTagHelper.cs | 2 +- zero/Utils/IdGenerator.cs | 4 +- zero/Utils/ObjectCopycat.cs | 4 +- zero/Utils/ObjectTraverser.cs | 16 ++++---- zero/Utils/Safenames.cs | 4 +- 27 files changed, 98 insertions(+), 137 deletions(-) delete mode 100644 zero.Raven/ZeroDocumentSession.cs diff --git a/zero.Raven/Extensions/RavenQueryableExtensions.cs b/zero.Raven/Extensions/RavenQueryableExtensions.cs index 3e27133d..7a776e52 100644 --- a/zero.Raven/Extensions/RavenQueryableExtensions.cs +++ b/zero.Raven/Extensions/RavenQueryableExtensions.cs @@ -10,7 +10,7 @@ public static class RavenQueryableExtensions { public static IOrderedQueryable OrderBy(this IQueryable 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 ThenBy(this IOrderedQueryable 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 SearchIf(this IQueryable source, Expression> fieldSelector, string searchTerms, string suffix = null, string prefix = null, SearchOperator @operator = SearchOperator.Or) { - if (string.IsNullOrWhiteSpace(searchTerms)) + if (String.IsNullOrWhiteSpace(searchTerms)) { return source; } diff --git a/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs b/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs index d009c2eb..b6be53b2 100644 --- a/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs +++ b/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs @@ -4,12 +4,12 @@ namespace zero.Raven; public static class ZeroDocumentSessionExtensions { - public static void SetCollection(this IZeroDocumentSession session, T model, string collectionName) + public static void SetCollection(this IAsyncDocumentSession session, T model, string collectionName) { session.Advanced.GetMetadataFor(model)[Rv.Constants.Documents.Metadata.Collection] = collectionName; } - public static void Expires(this IZeroDocumentSession session, T model, TimeSpan expires) + public static void Expires(this IAsyncDocumentSession session, T model, TimeSpan expires) { session.Advanced.GetMetadataFor(model)[Rv.Constants.Documents.Metadata.Expires] = DateTime.UtcNow.AddSeconds(expires.TotalSeconds); } diff --git a/zero.Raven/Operations/RavenOperations.Write.cs b/zero.Raven/Operations/RavenOperations.Write.cs index dc0b596b..8419d1de 100644 --- a/zero.Raven/Operations/RavenOperations.Write.cs +++ b/zero.Raven/Operations/RavenOperations.Write.cs @@ -6,13 +6,13 @@ namespace zero.Raven; public partial class RavenOperations : IRavenOperations { /// - public virtual Task> Create(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore); + public virtual Task> Create(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore); /// - public virtual Task> Update(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore, true); + public virtual Task> Update(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore, true); /// - protected virtual async Task> Save(T model, Func> validate = null, Action onAfterStore = null, bool update = false) where T : ZeroIdEntity, new() + protected virtual async Task> Save(T model, Func> validate = null, Action onAfterStore = null, bool update = false) where T : ZeroIdEntity, new() { if (model == null) { @@ -24,7 +24,7 @@ public partial class RavenOperations : IRavenOperations // check if the Id for a model already exists if (!model.Id.IsNullOrEmpty()) { - using (IZeroDocumentSession session = Store.Session(options: new Rv.Documents.Session.SessionOptions() { NoCaching = true })) + using (IAsyncDocumentSession session = Store.Session(options: new Rv.Documents.Session.SessionOptions() { NoCaching = true })) { previousModel = await session.LoadAsync(model.Id); } diff --git a/zero.Raven/Operations/RavenOperations.cs b/zero.Raven/Operations/RavenOperations.cs index 11530104..b34ab55c 100644 --- a/zero.Raven/Operations/RavenOperations.cs +++ b/zero.Raven/Operations/RavenOperations.cs @@ -11,7 +11,7 @@ namespace zero.Raven; public partial class RavenOperations : IRavenOperations { /// - public IZeroDocumentSession Session => Store.Session(); + public IAsyncDocumentSession Session => Store.Session(); protected record OperationOptions(bool IncludeInactive); @@ -41,7 +41,7 @@ public partial class RavenOperations : IRavenOperations /// public async Task GenerateId(T model) where T : ZeroIdEntity { - IZeroDocumentSession session = Session; + IAsyncDocumentSession session = Session; return await session.Advanced.DocumentStore.Conventions.GenerateDocumentIdAsync(session.Advanced.DocumentStore.Database, model); } @@ -138,7 +138,7 @@ public interface IRavenOperations /// /// Access to the current session /// - IZeroDocumentSession Session { get; } + IAsyncDocumentSession Session { get; } /// /// Get new instance of an entity (with an optional flavor) @@ -260,12 +260,12 @@ public interface IRavenOperations /// /// Creates an entity with an optional validator /// - Task> Create(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new(); + Task> Create(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new(); /// /// Updates an entity with an optional validator /// - Task> Update(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new(); + Task> Update(T model, Func> validate = null, Action onAfterStore = null) where T : ZeroIdEntity, new(); /// Task>> Sort(string[] sortedIds) where T : ZeroIdEntity, ISupportsSorting, new(); diff --git a/zero.Raven/RavenOptions.cs b/zero.Raven/RavenOptions.cs index f68719c0..35991042 100644 --- a/zero.Raven/RavenOptions.cs +++ b/zero.Raven/RavenOptions.cs @@ -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; diff --git a/zero.Raven/Tokens/Rfc6238AuthenticationService.cs b/zero.Raven/Tokens/Rfc6238AuthenticationService.cs index ba0bca65..5654900e 100644 --- a/zero.Raven/Tokens/Rfc6238AuthenticationService.cs +++ b/zero.Raven/Tokens/Rfc6238AuthenticationService.cs @@ -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; } diff --git a/zero.Raven/Tokens/ZeroTokenProvider.cs b/zero.Raven/Tokens/ZeroTokenProvider.cs index 60318077..49b7f8c3 100644 --- a/zero.Raven/Tokens/ZeroTokenProvider.cs +++ b/zero.Raven/Tokens/ZeroTokenProvider.cs @@ -43,7 +43,7 @@ public class ZeroTokenProvider : IZeroTokenProvider Metadata = metadata ?? new() }; - IZeroDocumentSession session = Store.Session(); + IAsyncDocumentSession session = Store.Session(); // saves the token await session.StoreAsync(securityToken); @@ -64,7 +64,7 @@ public class ZeroTokenProvider : IZeroTokenProvider return false; } - IZeroDocumentSession session = Store.Session(); + IAsyncDocumentSession session = Store.Session(); // try to find a valid token SecurityToken securityToken = await session.LoadAsync(TokenToId(token)); @@ -89,7 +89,7 @@ public class ZeroTokenProvider : IZeroTokenProvider return null; } - IZeroDocumentSession session = Store.Session(); + IAsyncDocumentSession session = Store.Session(); // try to find a valid token SecurityToken securityToken = await session.LoadAsync(TokenToId(token)); @@ -135,7 +135,7 @@ public class ZeroTokenProvider : IZeroTokenProvider return false; } - IZeroDocumentSession session = Store.Session(); + IAsyncDocumentSession session = Store.Session(); // try to find a valid token SecurityToken securityToken = await session.LoadAsync(TokenToId(token)); diff --git a/zero.Raven/Usings.cs b/zero.Raven/Usings.cs index b2a82ab9..5921d93f 100644 --- a/zero.Raven/Usings.cs +++ b/zero.Raven/Usings.cs @@ -16,4 +16,11 @@ global using zero.Rendering; global using zero.Validation; global using zero.Localization; global using zero.Context; -global using zero.Communication; \ No newline at end of file +global using zero.Communication; + +global using Raven.Client.Documents.Session; +global using Raven.Client.Documents; +global using Raven.Client.Documents.Operations; +global using Raven.Client.Documents.Queries; +global using Raven.Client.Documents.Session; +global using Raven.Client; \ No newline at end of file diff --git a/zero.Raven/ZeroDocumentSession.cs b/zero.Raven/ZeroDocumentSession.cs deleted file mode 100644 index 9f6bbe62..00000000 --- a/zero.Raven/ZeroDocumentSession.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Raven.Client.Documents; -using Raven.Client.Documents.Session; - -namespace zero.Raven; - -public class ZeroDocumentSession : AsyncDocumentSession, IZeroDocumentSession -{ - public IDocumentSession Synchronous => _synchronous ?? (_synchronous = DocumentStore.OpenSession(DatabaseName)); - - IDocumentSession _synchronous; - - public ZeroDocumentSession(DocumentStore documentStore, Guid id, SessionOptions options, string coreDatabase = null) : - base(documentStore, id, options) - { - } - - public bool IsDisposed { get; set; } - - public override void Dispose() - { - _synchronous?.Dispose(); - base.Dispose(); - } -} - - -public interface IZeroDocumentSession : IAsyncDocumentSession -{ - IDocumentSession Synchronous { get; } - - bool IsDisposed { get; } -} diff --git a/zero.Raven/ZeroStore.cs b/zero.Raven/ZeroStore.cs index 49389948..8d2e7a2a 100644 --- a/zero.Raven/ZeroStore.cs +++ b/zero.Raven/ZeroStore.cs @@ -16,7 +16,7 @@ public class ZeroStore : IZeroStore } protected IZeroOptions Options { get; set; } - protected Dictionary ScopedSessions { get; set; } = new(); + protected Dictionary ScopedSessions { get; set; } = new(); private const string NullDb = "__default__"; @@ -25,33 +25,19 @@ public class ZeroStore : IZeroStore /// - public IZeroDocumentSession Session(string database = null, ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null) + public IAsyncDocumentSession Session(ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null) { - string databaseKey = database ?? NullDb; - options ??= new SessionOptions(); - if (database.HasValue()) - { - options.Database = database; - } - if (resolution == ZeroSessionResolution.Create) { - return Raven.OpenAsyncSession(options) as IZeroDocumentSession; + return Raven.OpenAsyncSession(options); } - if (!ScopedSessions.TryGetValue(databaseKey, out IZeroDocumentSession session)) + if (!ScopedSessions.TryGetValue(Raven.Database, out IAsyncDocumentSession session)) { - session = Raven.OpenAsyncSession(options) as IZeroDocumentSession; - ScopedSessions.TryAdd(databaseKey, session); - } - - if (session.IsDisposed) - { - session = Raven.OpenAsyncSession(options) as IZeroDocumentSession; - ScopedSessions.Remove(databaseKey); - ScopedSessions.TryAdd(databaseKey, session); + session = Raven.OpenAsyncSession(options); + ScopedSessions.TryAdd(Raven.Database, session); } return session; @@ -106,7 +92,7 @@ public interface IZeroStore /// /// Use a specific session /// - IZeroDocumentSession Session(string database = null, ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null); + IAsyncDocumentSession Session(ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null); /// /// Purges a collection diff --git a/zero/Extensions/NumberExtensions.cs b/zero/Extensions/NumberExtensions.cs index be6c92bb..26f13f4f 100644 --- a/zero/Extensions/NumberExtensions.cs +++ b/zero/Extensions/NumberExtensions.cs @@ -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]); } } diff --git a/zero/Extensions/StringExtensions.cs b/zero/Extensions/StringExtensions.cs index 2d23e349..b6afa800 100644 --- a/zero/Extensions/StringExtensions.cs +++ b/zero/Extensions/StringExtensions.cs @@ -16,7 +16,7 @@ public static class StringExtensions public static string FullTrim(this string value) { - if (string.IsNullOrEmpty(value)) + if (String.IsNullOrEmpty(value)) { return value; } @@ -58,14 +58,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)) { @@ -77,8 +77,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)) { @@ -90,42 +90,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; } @@ -137,13 +137,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; } @@ -155,18 +155,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(); } @@ -177,7 +177,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; } diff --git a/zero/FileStorage/Paths.cs b/zero/FileStorage/Paths.cs index 27e91f7a..602ab9de 100644 --- a/zero/FileStorage/Paths.cs +++ b/zero/FileStorage/Paths.cs @@ -122,7 +122,7 @@ public class Paths : IPaths /// public string ToFilename(string value) { - if (string.IsNullOrWhiteSpace(value)) + if (String.IsNullOrWhiteSpace(value)) { return value; } diff --git a/zero/FileStorage/WebRootFileSystem.cs b/zero/FileStorage/WebRootFileSystem.cs index b9dee5d9..2e09cead 100644 --- a/zero/FileStorage/WebRootFileSystem.cs +++ b/zero/FileStorage/WebRootFileSystem.cs @@ -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('/'); } diff --git a/zero/Media/ImageSharp/PhysicalFileProvider.cs b/zero/Media/ImageSharp/PhysicalFileProvider.cs index e6145ff7..9366ae02 100644 --- a/zero/Media/ImageSharp/PhysicalFileProvider.cs +++ b/zero/Media/ImageSharp/PhysicalFileProvider.cs @@ -79,6 +79,6 @@ public class PhysicalFileProvider : IImageProvider List parts = path.Split('/').ToList(); parts.RemoveAt(parts.Count - 2); - return string.Join('/', parts); + return String.Join('/', parts); } } \ No newline at end of file diff --git a/zero/Media/MediaExtensions.cs b/zero/Media/MediaExtensions.cs index b3655856..e3a5ab50 100644 --- a/zero/Media/MediaExtensions.cs +++ b/zero/Media/MediaExtensions.cs @@ -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 round = input => decimal.Round(input, 0, MidpointRounding.ToEven).ToString(); - values = string.Format("{0}% {1}%", round(focalPoint.Left * 100), round(focalPoint.Top * 100)); + Func 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 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 (isZeroMedia) { // 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 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; diff --git a/zero/Media/MediaFileSystem.cs b/zero/Media/MediaFileSystem.cs index b6ac43ec..d90dfdde 100644 --- a/zero/Media/MediaFileSystem.cs +++ b/zero/Media/MediaFileSystem.cs @@ -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('/'); } diff --git a/zero/Metadata/MetadataService.cs b/zero/Metadata/MetadataService.cs index 57e6f706..51eef65b 100644 --- a/zero/Metadata/MetadataService.cs +++ b/zero/Metadata/MetadataService.cs @@ -34,7 +34,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 fragments = options.TitleFragments.Where(x => !x.IsNullOrWhiteSpace()).Reverse().ToHashSet(); diff --git a/zero/Numbers/Numbers.cs b/zero/Numbers/Numbers.cs index fa802a0e..9e35e537 100644 --- a/zero/Numbers/Numbers.cs +++ b/zero/Numbers/Numbers.cs @@ -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() && int.TryParse(options, out int oLength) && oLength > 0 && oLength <= 10) + if (!options.IsNullOrWhiteSpace() && Int32.TryParse(options, out int oLength) && oLength > 0 && oLength <= 10) { length = oLength; } - result = random.Next(0, int.MaxValue).ToString("D10").Substring(0, length); + result = random.Next(0, Int32.MaxValue).ToString("D10").Substring(0, length); } output = output.ReplaceFirst(original, result); diff --git a/zero/Rendering/RazorRenderer.cs b/zero/Rendering/RazorRenderer.cs index 90250215..98b08fa1 100644 --- a/zero/Rendering/RazorRenderer.cs +++ b/zero/Rendering/RazorRenderer.cs @@ -243,7 +243,7 @@ public class RazorRenderer : IRazorRenderer, IDisposable } IEnumerable 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); } @@ -267,7 +267,7 @@ public class RazorRenderer : IRazorRenderer, IDisposable } IEnumerable 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); } diff --git a/zero/Routing/RequestUrlResolver.cs b/zero/Routing/RequestUrlResolver.cs index 9fd82154..0e605b5b 100644 --- a/zero/Routing/RequestUrlResolver.cs +++ b/zero/Routing/RequestUrlResolver.cs @@ -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; diff --git a/zero/TagHelpers/ClassTagHelper.cs b/zero/TagHelpers/ClassTagHelper.cs index 315c23db..af0805db 100644 --- a/zero/TagHelpers/ClassTagHelper.cs +++ b/zero/TagHelpers/ClassTagHelper.cs @@ -24,14 +24,14 @@ public class ClassTagHelper : TagHelper { var items = _classValues.Where(e => e.Value).Select(e => e.Key).ToList(); - if (!string.IsNullOrEmpty(Classes)) + if (!String.IsNullOrEmpty(Classes)) { items.Insert(0, Classes); } if (items.Any()) { - var classes = string.Join(" ", items.ToArray()); + var classes = String.Join(" ", items.ToArray()); output.Attributes.Add("class", classes); } } diff --git a/zero/TagHelpers/StripHtmlTagHelper.cs b/zero/TagHelpers/StripHtmlTagHelper.cs index 61d1d96d..93f26839 100644 --- a/zero/TagHelpers/StripHtmlTagHelper.cs +++ b/zero/TagHelpers/StripHtmlTagHelper.cs @@ -18,7 +18,7 @@ public class StripHtmlTagHelper : TagHelper output.TagName = string.Empty; string text = string.Empty; - if (!string.IsNullOrWhiteSpace(Text)) + if (!String.IsNullOrWhiteSpace(Text)) { text = WebUtility.HtmlDecode(Regex.Replace(Text, "<[^>]*(>|$)", string.Empty).Trim()); diff --git a/zero/Utils/IdGenerator.cs b/zero/Utils/IdGenerator.cs index 7b8bbf25..86155bd2 100644 --- a/zero/Utils/IdGenerator.cs +++ b/zero/Utils/IdGenerator.cs @@ -43,7 +43,7 @@ public class IdGenerator /// 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 /// 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); } diff --git a/zero/Utils/ObjectCopycat.cs b/zero/Utils/ObjectCopycat.cs index 29c71881..5e5678f2 100644 --- a/zero/Utils/ObjectCopycat.cs +++ b/zero/Utils/ObjectCopycat.cs @@ -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); } } diff --git a/zero/Utils/ObjectTraverser.cs b/zero/Utils/ObjectTraverser.cs index 49157b6b..f5de7b9c 100644 --- a/zero/Utils/ObjectTraverser.cs +++ b/zero/Utils/ObjectTraverser.cs @@ -21,7 +21,7 @@ public class ObjectTraverser HashSet exploredObjects = new HashSet(); List> found = new List>(); - Find(value, null, string.Empty, null, exploredObjects, found); + Find(value, null, String.Empty, null, exploredObjects, found); return found; } @@ -35,7 +35,7 @@ public class ObjectTraverser HashSet exploredObjects = new HashSet(); List found = new List(); - 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 exploredObjects = new HashSet(); List> found = new List>(); - FindAttribute(value, null, string.Empty, null, exploredObjects, found); + FindAttribute(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(item, value, CombineKey(string.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), property, exploredObjects, found); + Find(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(item, value, CombineKey(string.Empty, key, SQBKT_OPEN + idx + SQBKT_CLOSE), null, exploredObjects, found); + FindAttribute(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); } diff --git a/zero/Utils/Safenames.cs b/zero/Utils/Safenames.cs index 9b7ba189..bcef4901 100644 --- a/zero/Utils/Safenames.cs +++ b/zero/Utils/Safenames.cs @@ -50,9 +50,9 @@ public class Safenames /// static string Generate(string value, Scope scope) { - if (string.IsNullOrWhiteSpace(value)) + if (String.IsNullOrWhiteSpace(value)) { - return string.Empty; + return String.Empty; } char previous = default;