remove zero.documentsession
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;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ namespace zero.Raven;
|
||||
|
||||
public static class ZeroDocumentSessionExtensions
|
||||
{
|
||||
public static void SetCollection<T>(this IZeroDocumentSession session, T model, string collectionName)
|
||||
public static void SetCollection<T>(this IAsyncDocumentSession session, T model, string collectionName)
|
||||
{
|
||||
session.Advanced.GetMetadataFor(model)[Rv.Constants.Documents.Metadata.Collection] = collectionName;
|
||||
}
|
||||
|
||||
public static void Expires<T>(this IZeroDocumentSession session, T model, TimeSpan expires)
|
||||
public static void Expires<T>(this IAsyncDocumentSession session, T model, TimeSpan expires)
|
||||
{
|
||||
session.Advanced.GetMetadataFor(model)[Rv.Constants.Documents.Metadata.Expires] = DateTime.UtcNow.AddSeconds(expires.TotalSeconds);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace zero.Raven;
|
||||
public partial class RavenOperations : IRavenOperations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IZeroDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore);
|
||||
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore);
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IZeroDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore, true);
|
||||
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new() => Save(model, validate, onAfterStore, true);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IZeroDocumentSession> onAfterStore = null, bool update = false) where T : ZeroIdEntity, new()
|
||||
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> 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<T>(model.Id);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace zero.Raven;
|
||||
public partial class RavenOperations : IRavenOperations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IZeroDocumentSession Session => Store.Session();
|
||||
public IAsyncDocumentSession Session => Store.Session();
|
||||
|
||||
protected record OperationOptions(bool IncludeInactive);
|
||||
|
||||
@@ -41,7 +41,7 @@ public partial class RavenOperations : IRavenOperations
|
||||
/// <inheritdoc />
|
||||
public async Task<string> GenerateId<T>(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
|
||||
/// <summary>
|
||||
/// Access to the current session
|
||||
/// </summary>
|
||||
IZeroDocumentSession Session { get; }
|
||||
IAsyncDocumentSession Session { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get new instance of an entity (with an optional flavor)
|
||||
@@ -260,12 +260,12 @@ public interface IRavenOperations
|
||||
/// <summary>
|
||||
/// Creates an entity with an optional validator
|
||||
/// </summary>
|
||||
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IZeroDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new();
|
||||
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new();
|
||||
|
||||
/// <summary>
|
||||
/// Updates an entity with an optional validator
|
||||
/// </summary>
|
||||
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IZeroDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new();
|
||||
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : ZeroIdEntity, new();
|
||||
|
||||
/// <inheritdoc />
|
||||
Task<Result<IOrderedEnumerable<T>>> Sort<T>(string[] sortedIds) where T : ZeroIdEntity, ISupportsSorting, new();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<SecurityToken>(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<SecurityToken>(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<SecurityToken>(TokenToId(token));
|
||||
|
||||
@@ -16,4 +16,11 @@ global using zero.Rendering;
|
||||
global using zero.Validation;
|
||||
global using zero.Localization;
|
||||
global using zero.Context;
|
||||
global using zero.Communication;
|
||||
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;
|
||||
@@ -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; }
|
||||
}
|
||||
+7
-21
@@ -16,7 +16,7 @@ public class ZeroStore : IZeroStore
|
||||
}
|
||||
|
||||
protected IZeroOptions Options { get; set; }
|
||||
protected Dictionary<string, IZeroDocumentSession> ScopedSessions { get; set; } = new();
|
||||
protected Dictionary<string, IAsyncDocumentSession> ScopedSessions { get; set; } = new();
|
||||
private const string NullDb = "__default__";
|
||||
|
||||
|
||||
@@ -25,33 +25,19 @@ public class ZeroStore : IZeroStore
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
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
|
||||
/// <summary>
|
||||
/// Use a specific session
|
||||
/// </summary>
|
||||
IZeroDocumentSession Session(string database = null, ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null);
|
||||
IAsyncDocumentSession Session(ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null);
|
||||
|
||||
/// <summary>
|
||||
/// Purges a collection
|
||||
|
||||
@@ -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() && 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);
|
||||
|
||||
@@ -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