upgrade packages; remove zero.documentstore
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;
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ public partial class RavenOperations : IRavenOperations
|
||||
var collectionName = Store.Raven.Conventions.FindCollectionName(typeof(T));
|
||||
var operationQuery = new DeleteByQueryOperation(new IndexQuery()
|
||||
{
|
||||
Query = $"from {collectionName} c {querySuffix ?? String.Empty}",
|
||||
Query = $"from {collectionName} c {querySuffix ?? string.Empty}",
|
||||
QueryParameters = parameters
|
||||
}, new QueryOperationOptions { AllowStale = true });
|
||||
|
||||
Operation operation = await Store.Raven.GetOperationExecutor().SendAsync(operationQuery);
|
||||
Operation operation = await Store.Raven.Operations.SendAsync(operationQuery);
|
||||
await operation.WaitForCompletionAsync();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
using Raven.Client;
|
||||
using Raven.Client.Documents;
|
||||
using Raven.Client.Documents.BulkInsert;
|
||||
using Raven.Client.Documents.Operations;
|
||||
using Raven.Client.Documents.Queries;
|
||||
using Raven.Client.Documents.Session;
|
||||
|
||||
namespace zero.Raven;
|
||||
|
||||
public class ZeroDocumentStore : DocumentStore, IZeroDocumentStore
|
||||
{
|
||||
public ZeroDocumentStore(IZeroOptions options) : base()
|
||||
{
|
||||
Options = options.For<RavenOptions>();
|
||||
Database = null;
|
||||
}
|
||||
|
||||
protected RavenOptions Options { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ResolvedDatabase { get; set; }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationExecutor GetOperationExecutor(string database = null)
|
||||
{
|
||||
return Operations.ForDatabase(database ?? ResolvedDatabase);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IAsyncDocumentSession OpenAsyncSession(string database)
|
||||
{
|
||||
return OpenAsyncSession(new SessionOptions()
|
||||
{
|
||||
Database = database
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IAsyncDocumentSession OpenAsyncSession(SessionOptions options)
|
||||
{
|
||||
options.Database = options.Database ?? ResolvedDatabase;
|
||||
|
||||
AssertInitialized();
|
||||
EnsureNotClosed();
|
||||
|
||||
var sessionId = Guid.NewGuid();
|
||||
var session = new ZeroDocumentSession(this, sessionId, options, Options.Database);
|
||||
RegisterEvents(session);
|
||||
AfterSessionCreated(session);
|
||||
session.OnSessionDisposing += (sender, args) =>
|
||||
{
|
||||
session.IsDisposed = true;
|
||||
};
|
||||
|
||||
session.Advanced.WaitForIndexesAfterSaveChanges(TimeSpan.FromSeconds(0.5), throwOnTimeout: false);
|
||||
session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(Options.CacheInMinutes), options.Database);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IAsyncDocumentSession OpenAsyncSession()
|
||||
{
|
||||
return OpenAsyncSession(new SessionOptions()
|
||||
{
|
||||
Database = ResolvedDatabase
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDocumentSession OpenSession(SessionOptions options)
|
||||
{
|
||||
options.Database = options.Database ?? ResolvedDatabase;
|
||||
|
||||
AssertInitialized();
|
||||
EnsureNotClosed();
|
||||
|
||||
var sessionId = Guid.NewGuid();
|
||||
var session = new DocumentSession(this, sessionId, options);
|
||||
RegisterEvents(session);
|
||||
AfterSessionCreated(session);
|
||||
|
||||
session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromHours(1), options.Database);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDocumentSession OpenSession(string database)
|
||||
{
|
||||
return OpenSession(new SessionOptions()
|
||||
{
|
||||
Database = database
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDocumentSession OpenSession()
|
||||
{
|
||||
return OpenSession(new SessionOptions()
|
||||
{
|
||||
Database = ResolvedDatabase
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override BulkInsertOperation BulkInsert(string database = null, CancellationToken token = default)
|
||||
{
|
||||
return base.BulkInsert(database ?? ResolvedDatabase, token);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task PurgeAsync<T>(string database = null, string querySuffix = null, Parameters parameters = null)
|
||||
{
|
||||
var collectionName = Conventions.FindCollectionName(typeof(T));
|
||||
var operationQuery = new DeleteByQueryOperation(new IndexQuery()
|
||||
{
|
||||
Query = $"from {collectionName} c {querySuffix ?? String.Empty}",
|
||||
QueryParameters = parameters
|
||||
}, new QueryOperationOptions { AllowStale = true });
|
||||
|
||||
Operation operation = await GetOperationExecutor(database ?? ResolvedDatabase).SendAsync(operationQuery);
|
||||
|
||||
await operation.WaitForCompletionAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface IZeroDocumentStore : IDocumentStore
|
||||
{
|
||||
/// <summary>
|
||||
/// The database which has been resolved from the current application
|
||||
/// </summary>
|
||||
string ResolvedDatabase { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get operation executor
|
||||
/// </summary>
|
||||
OperationExecutor GetOperationExecutor(string database = null);
|
||||
|
||||
/// <summary>
|
||||
/// Purges a collection
|
||||
/// </summary>
|
||||
Task PurgeAsync<T>(string database = null, string querySuffix = null, Parameters parameters = null);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ internal class ZeroRavenModule : ZeroModule
|
||||
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSingleton<IRavenDocumentConventionsBuilder, RavenDocumentConventionsBuilder>();
|
||||
services.AddSingleton<IZeroDocumentStore, ZeroDocumentStore>(CreateRavenStore);
|
||||
services.AddSingleton<IDocumentStore>(CreateRavenStore);
|
||||
services.AddScoped<IZeroStore, ZeroStore>();
|
||||
services.AddScoped<IZeroTokenProvider, ZeroTokenProvider>();
|
||||
services.AddScoped<StoreContext>();
|
||||
@@ -43,13 +43,13 @@ internal class ZeroRavenModule : ZeroModule
|
||||
/// <summary>
|
||||
/// Creates and configures the raven store
|
||||
/// </summary>
|
||||
protected ZeroDocumentStore CreateRavenStore(IServiceProvider services)
|
||||
protected IDocumentStore CreateRavenStore(IServiceProvider services)
|
||||
{
|
||||
IZeroOptions options = services.GetService<IZeroOptions>();
|
||||
RavenOptions ravenOptions = options.For<RavenOptions>();
|
||||
IRavenDocumentConventionsBuilder conventionsBuilder = services.GetService<IRavenDocumentConventionsBuilder>();
|
||||
|
||||
IZeroDocumentStore store = new ZeroDocumentStore(options)
|
||||
IDocumentStore store = new DocumentStore()
|
||||
{
|
||||
Database = ravenOptions.Database,
|
||||
Urls = new string[1] { ravenOptions.Url },
|
||||
@@ -72,6 +72,6 @@ internal class ZeroRavenModule : ZeroModule
|
||||
IndexCreation.CreateIndexes(indexes, store, database: ravenOptions.Database);
|
||||
|
||||
|
||||
return (ZeroDocumentStore)raven;
|
||||
return raven;
|
||||
}
|
||||
}
|
||||
+48
-4
@@ -1,10 +1,14 @@
|
||||
using Raven.Client.Documents.Session;
|
||||
using Raven.Client.Documents;
|
||||
using Raven.Client.Documents.Operations;
|
||||
using Raven.Client.Documents.Queries;
|
||||
using Raven.Client.Documents.Session;
|
||||
using Raven.Client;
|
||||
|
||||
namespace zero.Raven;
|
||||
|
||||
public class ZeroStore : IZeroStore
|
||||
{
|
||||
public ZeroStore(IZeroDocumentStore raven, IZeroOptions options) : base()
|
||||
public ZeroStore(IDocumentStore raven, IZeroOptions options) : base()
|
||||
{
|
||||
Options = options;
|
||||
Raven = raven;
|
||||
@@ -17,7 +21,7 @@ public class ZeroStore : IZeroStore
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public IZeroDocumentStore Raven { get; private set; }
|
||||
public IDocumentStore Raven { get; private set; }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -52,6 +56,36 @@ public class ZeroStore : IZeroStore
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task PurgeAsync<T>(string querySuffix = null, Parameters parameters = null)
|
||||
{
|
||||
string collectionName = Raven.Conventions.FindCollectionName(typeof(T));
|
||||
DeleteByQueryOperation operationQuery = new DeleteByQueryOperation(new IndexQuery()
|
||||
{
|
||||
Query = $"from {collectionName} c {querySuffix ?? string.Empty}",
|
||||
QueryParameters = parameters
|
||||
}, new QueryOperationOptions { AllowStale = true });
|
||||
|
||||
Operation operation = await Raven.Operations.SendAsync(operationQuery);
|
||||
|
||||
await operation.WaitForCompletionAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Purge<T>(string querySuffix = null, Parameters parameters = null)
|
||||
{
|
||||
string collectionName = Raven.Conventions.FindCollectionName(typeof(T));
|
||||
DeleteByQueryOperation operationQuery = new DeleteByQueryOperation(new IndexQuery()
|
||||
{
|
||||
Query = $"from {collectionName} c {querySuffix ?? string.Empty}",
|
||||
QueryParameters = parameters
|
||||
}, new QueryOperationOptions { AllowStale = true });
|
||||
|
||||
Raven.Operations.Send(operationQuery);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +101,20 @@ public interface IZeroStore
|
||||
/// <summary>
|
||||
/// Get underlying raven document store
|
||||
/// </summary>
|
||||
IZeroDocumentStore Raven { get; }
|
||||
IDocumentStore Raven { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Use a specific session
|
||||
/// </summary>
|
||||
IZeroDocumentSession Session(string database = null, ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null);
|
||||
|
||||
/// <summary>
|
||||
/// Purges a collection
|
||||
/// </summary>
|
||||
Task PurgeAsync<T>(string querySuffix = null, Parameters parameters = null);
|
||||
|
||||
/// <summary>
|
||||
/// Purges a collection
|
||||
/// </summary>
|
||||
void Purge<T>(string querySuffix = null, Parameters parameters = null);
|
||||
}
|
||||
@@ -3,8 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<PackageId>zero.Raven</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<RootNamespace>zero.Raven</RootNamespace>
|
||||
<DebugType>embedded</DebugType>
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 (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<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('/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<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);
|
||||
|
||||
@@ -243,7 +243,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);
|
||||
}
|
||||
@@ -267,7 +267,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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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