diff --git a/.gitignore b/.gitignore index ee66b814..058edd64 100644 --- a/.gitignore +++ b/.gitignore @@ -259,21 +259,4 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc - -# Media folder + app_data -App_Data/ -**/wwwroot/Media/ -**/wwwroot/Uploads/ -Temp/ -**/Assets/**/app.* -**/Assets/**/setup.* -**/Assets/**/*.js -deps/*.dll -zero.Commerce/ -zero.Stories/ -zero.Forms/ -zero.Backoffice.UI/package.json -zero.Backoffice.UI/package-lock.json -zero.Backoffice.UI/app/core/plugins.js -zero.Backoffice.UI/dist +*.pyc \ No newline at end of file diff --git a/zero.Raven/DbProviders/RavenIdentityStoreDbProvider.cs b/Finch.Raven/DbProviders/RavenIdentityStoreDbProvider.cs similarity index 70% rename from zero.Raven/DbProviders/RavenIdentityStoreDbProvider.cs rename to Finch.Raven/DbProviders/RavenIdentityStoreDbProvider.cs index 02fbac3e..b18e8980 100644 --- a/zero.Raven/DbProviders/RavenIdentityStoreDbProvider.cs +++ b/Finch.Raven/DbProviders/RavenIdentityStoreDbProvider.cs @@ -1,10 +1,10 @@ using System.Linq.Expressions; using Raven.Client.Documents; -using zero.Identity; +using Finch.Identity; -namespace zero.Raven; +namespace Finch.Raven; -public class RavenIdentityStoreDbProvider : IZeroIdentityStoreDbProvider +public class RavenIdentityStoreDbProvider : IFinchIdentityStoreDbProvider { protected IRavenOperations Ops { get; set; } @@ -15,27 +15,27 @@ public class RavenIdentityStoreDbProvider : IZeroIdentityStoreDbProvider } - public Task Load(string id, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task Load(string id, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Load(id); - public Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity => + public Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity => Ops.Session.Query().FirstOrDefaultAsync(expression, ct); public async Task> FindAll(Expression> expression, CancellationToken ct = default) - where T : ZeroEntity => + where T : FinchEntity => await Ops.Session.Query().Where(expression).ToListAsync(ct); - public Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Create(model); - public Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Update(model); - public Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Delete(model); } \ No newline at end of file diff --git a/zero.Raven/DbProviders/RavenMediaStoreDbProvider.cs b/Finch.Raven/DbProviders/RavenMediaStoreDbProvider.cs similarity index 70% rename from zero.Raven/DbProviders/RavenMediaStoreDbProvider.cs rename to Finch.Raven/DbProviders/RavenMediaStoreDbProvider.cs index 6ae93d04..77bf8252 100644 --- a/zero.Raven/DbProviders/RavenMediaStoreDbProvider.cs +++ b/Finch.Raven/DbProviders/RavenMediaStoreDbProvider.cs @@ -1,10 +1,10 @@ using System.Linq.Expressions; using Raven.Client.Documents; -using zero.Media; +using Finch.Media; -namespace zero.Raven; +namespace Finch.Raven; -public class RavenMediaStoreDbProvider : IZeroMediaStoreDbProvider +public class RavenMediaStoreDbProvider : IFinchMediaStoreDbProvider { protected IRavenOperations Ops { get; set; } @@ -15,23 +15,23 @@ public class RavenMediaStoreDbProvider : IZeroMediaStoreDbProvider } - public Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity => + public Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity => Ops.Session.Query().FirstOrDefaultAsync(expression, ct); public async Task> FindAll(Expression> expression, CancellationToken ct = default) - where T : ZeroEntity => + where T : FinchEntity => await Ops.Session.Query().Where(expression).ToListAsync(ct); - public Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Create(model); - public Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Update(model); - public Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Delete(model); } \ No newline at end of file diff --git a/zero.Raven/DbProviders/RavenNumberStoreDbProvider.cs b/Finch.Raven/DbProviders/RavenNumberStoreDbProvider.cs similarity index 70% rename from zero.Raven/DbProviders/RavenNumberStoreDbProvider.cs rename to Finch.Raven/DbProviders/RavenNumberStoreDbProvider.cs index c1d1a4bf..6bf983b7 100644 --- a/zero.Raven/DbProviders/RavenNumberStoreDbProvider.cs +++ b/Finch.Raven/DbProviders/RavenNumberStoreDbProvider.cs @@ -1,10 +1,10 @@ using Raven.Client.Documents; using System.Linq.Expressions; -using zero.Numbers; +using Finch.Numbers; -namespace zero.Raven; +namespace Finch.Raven; -public class RavenNumberStoreDbProvider : IZeroNumberStoreDbProvider +public class RavenNumberStoreDbProvider : IFinchNumberStoreDbProvider { protected IRavenOperations Ops { get; set; } @@ -15,27 +15,27 @@ public class RavenNumberStoreDbProvider : IZeroNumberStoreDbProvider } - public Task Load(string id, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task Load(string id, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Load(id); - public Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity => + public Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity => Ops.Session.Query().FirstOrDefaultAsync(expression, ct); public async Task> FindAll(Expression> expression, CancellationToken ct = default) - where T : ZeroEntity => + where T : FinchEntity => await Ops.Session.Query().Where(expression).ToListAsync(ct); - public Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Create(model); - public Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Update(model); - public Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new() => + public Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new() => Ops.Delete(model); } \ No newline at end of file diff --git a/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs b/Finch.Raven/Extensions/FinchDocumentSessionExtensions.cs similarity index 86% rename from zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs rename to Finch.Raven/Extensions/FinchDocumentSessionExtensions.cs index b6be53b2..efef28fe 100644 --- a/zero.Raven/Extensions/ZeroDocumentSessionExtensions.cs +++ b/Finch.Raven/Extensions/FinchDocumentSessionExtensions.cs @@ -1,8 +1,8 @@ using Rv = Raven.Client; -namespace zero.Raven; +namespace Finch.Raven; -public static class ZeroDocumentSessionExtensions +public static class FinchDocumentSessionExtensions { public static void SetCollection(this IAsyncDocumentSession session, T model, string collectionName) { diff --git a/zero.Raven/Extensions/RavenQueryableExtensions.cs b/Finch.Raven/Extensions/RavenQueryableExtensions.cs similarity index 98% rename from zero.Raven/Extensions/RavenQueryableExtensions.cs rename to Finch.Raven/Extensions/RavenQueryableExtensions.cs index 7a776e52..bc5a27a9 100644 --- a/zero.Raven/Extensions/RavenQueryableExtensions.cs +++ b/Finch.Raven/Extensions/RavenQueryableExtensions.cs @@ -4,7 +4,7 @@ using Raven.Client.Documents.Queries; using Raven.Client.Documents.Session; using System.Linq.Expressions; -namespace zero.Raven; +namespace Finch.Raven; public static class RavenQueryableExtensions { @@ -49,7 +49,7 @@ public static class RavenQueryableExtensions if (pageNumber <= 0 || pageSize <= 0) { - throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero"); + throw new NotSupportedException("Both pageNumber and pageSize must be greater than z_ero"); } return source.Skip((pageNumber - 1) * pageSize).Take(pageSize); diff --git a/zero.Raven/Extensions/ValidatorExtensions.cs b/Finch.Raven/Extensions/ValidatorExtensions.cs similarity index 90% rename from zero.Raven/Extensions/ValidatorExtensions.cs rename to Finch.Raven/Extensions/ValidatorExtensions.cs index e96bd098..5dc181d2 100644 --- a/zero.Raven/Extensions/ValidatorExtensions.cs +++ b/Finch.Raven/Extensions/ValidatorExtensions.cs @@ -1,7 +1,7 @@ using FluentValidation; using Raven.Client.Documents; -namespace zero.Raven; +namespace Finch.Raven; public static class ValidatorExtensions { @@ -9,12 +9,12 @@ public static class ValidatorExtensions /// Check if this value is unique within a collection /// public static IRuleBuilderOptions Unique(this IRuleBuilder ruleBuilder, IRavenOperations ops) - where T : ZeroIdEntity + where T : FinchIdEntity { return ruleBuilder.MustAsync(async (entity, value, context, cancellation) => { bool any = await ops.Session.Advanced.AsyncDocumentQuery() - .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id) + .WhereNotEquals(nameof(FinchIdEntity.Id), entity.Id) .WhereEquals(context.PropertyPath.ToPascalCaseId(), value) .AnyAsync(cancellation); @@ -43,12 +43,12 @@ public static class ValidatorExtensions /// Check if this value is at least set once to the expected value within a collection /// public static IRuleBuilderOptions ExpectAnyUnique(this IRuleBuilder ruleBuilder, IRavenOperations ops, TProperty expectedValue) - where T : ZeroIdEntity + where T : FinchIdEntity { return ruleBuilder.MustAsync(async (entity, value, context, cancellation) => { return await ops.Session.Advanced.AsyncDocumentQuery() - .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id) + .WhereNotEquals(nameof(FinchIdEntity.Id), entity.Id) .WhereEquals(context.PropertyPath.ToPascalCaseId(), expectedValue) .AnyAsync(cancellation); }).WithMessage("@errors.forms.not_unique_alone"); @@ -59,7 +59,7 @@ public static class ValidatorExtensions /// Check if this reference exists and is an entity which can be referenced /// public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IRavenOperations ops) - where T : ZeroIdEntity + where T : FinchIdEntity { return ruleBuilder.Exists(ops); } @@ -69,7 +69,7 @@ public static class ValidatorExtensions /// Check if this reference exists and is an entity which can be referenced /// public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IRavenOperations ops) - where TCollection : ZeroIdEntity + where TCollection : FinchIdEntity { return ruleBuilder.MustAsync(async (entity, id, context, cancellation) => { diff --git a/zero.Raven/zero.Raven.csproj b/Finch.Raven/Finch.Raven.csproj similarity index 81% rename from zero.Raven/zero.Raven.csproj rename to Finch.Raven/Finch.Raven.csproj index 55c94d1a..e6680d3f 100644 --- a/zero.Raven/zero.Raven.csproj +++ b/Finch.Raven/Finch.Raven.csproj @@ -1,11 +1,11 @@ - zero.Raven + Finch.Raven 1.0.0 net8.0;net9.0;net10.0 true - zero.Raven + Finch.Raven embedded @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/zero.Raven/ZeroRavenModule.cs b/Finch.Raven/FinchRavenModule.cs similarity index 66% rename from zero.Raven/ZeroRavenModule.cs rename to Finch.Raven/FinchRavenModule.cs index 077148c6..f49b10b9 100644 --- a/zero.Raven/ZeroRavenModule.cs +++ b/Finch.Raven/FinchRavenModule.cs @@ -4,39 +4,39 @@ using Microsoft.Extensions.DependencyInjection; using Raven.Client.Documents; using Raven.Client.Documents.Indexes; using Raven.Client.Http; -using zero.Identity; -using zero.Media; -using zero.Numbers; +using Finch.Identity; +using Finch.Media; +using Finch.Numbers; -namespace zero.Raven; +namespace Finch.Raven; -public static class ZeroBuilderExtensions +public static class FinchBuilderExtensions { - public static ZeroBuilder AddRavenDb(this ZeroBuilder builder) + public static FinchBuilder AddRavenDb(this FinchBuilder builder) { - builder.AddModule(); + builder.AddModule(); return builder; } } -internal class ZeroRavenModule : ZeroModule +internal class FinchRavenModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); services.AddSingleton(CreateRavenStore); - services.AddScoped(); - services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddTransient(); services.AddScoped(); - services.Replace(ServiceLifetime.Scoped); - services.Replace(ServiceLifetime.Scoped); - services.Replace(ServiceLifetime.Scoped); + services.Replace(ServiceLifetime.Scoped); + services.Replace(ServiceLifetime.Scoped); + services.Replace(ServiceLifetime.Scoped); services.AddOptions(); - services.AddOptions().Bind(configuration.GetSection("Zero:Raven")); + services.AddOptions().Bind(configuration.GetSection("Finch:Raven")); services.ConfigureOptions(); } @@ -45,7 +45,7 @@ internal class ZeroRavenModule : ZeroModule /// protected IDocumentStore CreateRavenStore(IServiceProvider services) { - IZeroOptions options = services.GetService(); + IFinchOptions options = services.GetService(); RavenOptions ravenOptions = options.For(); IRavenDocumentConventionsBuilder conventionsBuilder = services.GetService(); @@ -68,7 +68,7 @@ internal class ZeroRavenModule : ZeroModule IDocumentStore raven = store.Initialize(); // create all indexes - IEnumerable indexes = ravenOptions.Indexes.BuildAll(options, store); + IEnumerable indexes = ravenOptions.Indexes.BuildAll(options, store); IndexCreation.CreateIndexes(indexes, store, database: ravenOptions.Database); diff --git a/zero.Raven/ZeroStore.cs b/Finch.Raven/FinchStore.cs similarity index 80% rename from zero.Raven/ZeroStore.cs rename to Finch.Raven/FinchStore.cs index 8d2e7a2a..4e33120e 100644 --- a/zero.Raven/ZeroStore.cs +++ b/Finch.Raven/FinchStore.cs @@ -4,18 +4,18 @@ using Raven.Client.Documents.Queries; using Raven.Client.Documents.Session; using Raven.Client; -namespace zero.Raven; +namespace Finch.Raven; -public class ZeroStore : IZeroStore +public class FinchStore : IFinchStore { - public ZeroStore(IDocumentStore raven, IZeroOptions options) : base() + public FinchStore(IDocumentStore raven, IFinchOptions options) : base() { Options = options; Raven = raven; //Database = null; } - protected IZeroOptions Options { get; set; } + protected IFinchOptions Options { get; set; } protected Dictionary ScopedSessions { get; set; } = new(); private const string NullDb = "__default__"; @@ -25,11 +25,11 @@ public class ZeroStore : IZeroStore /// - public IAsyncDocumentSession Session(ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null) + public IAsyncDocumentSession Session(FinchSessionResolution resolution = FinchSessionResolution.Reuse, SessionOptions options = null) { options ??= new SessionOptions(); - if (resolution == ZeroSessionResolution.Create) + if (resolution == FinchSessionResolution.Create) { return Raven.OpenAsyncSession(options); } @@ -75,14 +75,14 @@ public class ZeroStore : IZeroStore } -public enum ZeroSessionResolution +public enum FinchSessionResolution { Reuse = 0, Create = 1 } -public interface IZeroStore +public interface IFinchStore { /// /// Get underlying raven document store @@ -92,7 +92,7 @@ public interface IZeroStore /// /// Use a specific session /// - IAsyncDocumentSession Session(ZeroSessionResolution resolution = ZeroSessionResolution.Reuse, SessionOptions options = null); + IAsyncDocumentSession Session(FinchSessionResolution resolution = FinchSessionResolution.Reuse, SessionOptions options = null); /// /// Purges a collection diff --git a/zero.Raven/Indexes/ZeroIndex.cs b/Finch.Raven/Indexes/FinchIndex.cs similarity index 94% rename from zero.Raven/Indexes/ZeroIndex.cs rename to Finch.Raven/Indexes/FinchIndex.cs index 0c13387e..20876207 100644 --- a/zero.Raven/Indexes/ZeroIndex.cs +++ b/Finch.Raven/Indexes/FinchIndex.cs @@ -4,15 +4,15 @@ using Raven.Client.Documents.Indexes.Spatial; using Raven.Client.Documents.Operations.Attachments; using System.Linq.Expressions; -namespace zero.Raven; +namespace Finch.Raven; -public abstract class ZeroJavascriptIndex : AbstractJavaScriptIndexCreationTask, IZeroIndexDefinition +public abstract class FinchJavascriptIndex : AbstractJavaScriptIndexCreationTask, IFinchIndexDefinition { - public ZeroJavascriptIndex() { Create(); } + public FinchJavascriptIndex() { Create(); } protected virtual void Create() { } - public virtual void Setup(IZeroOptions options, IDocumentStore store) { } + public virtual void Setup(IFinchOptions options, IDocumentStore store) { } public new string Reduce { get => base.Reduce; set => base.Reduce = value; } public new string OutputReduceToCollection { get => base.OutputReduceToCollection; set => base.OutputReduceToCollection = value; } @@ -44,12 +44,12 @@ public abstract class ZeroJavascriptIndex : AbstractJavaScriptIndexCreationTask, public new T? TryConvert(object value) where T : struct => base.TryConvert(value); } -public abstract class ZeroMultiMapIndex : AbstractMultiMapIndexCreationTask, IZeroIndexDefinition +public abstract class FinchMultiMapIndex : AbstractMultiMapIndexCreationTask, IFinchIndexDefinition { - public ZeroMultiMapIndex() { Create(); } + public FinchMultiMapIndex() { Create(); } protected virtual void Create() { } - public virtual void Setup(IZeroOptions options, IDocumentStore store) { } + public virtual void Setup(IFinchOptions options, IDocumentStore store) { } // AbstractMultiMapIndexCreationTask public new void AddMap(Expression, IEnumerable>> map) => base.AddMap(map); @@ -111,12 +111,12 @@ public abstract class ZeroMultiMapIndex : AbstractMultiMapIndexCreationTask : AbstractMultiMapIndexCreationTask, IZeroIndexDefinition +public abstract class FinchMultiMapIndex : AbstractMultiMapIndexCreationTask, IFinchIndexDefinition { - public ZeroMultiMapIndex() { Create(); } + public FinchMultiMapIndex() { Create(); } protected virtual void Create() { } - public virtual void Setup(IZeroOptions options, IDocumentStore store) { } + public virtual void Setup(IFinchOptions options, IDocumentStore store) { } // AbstractMultiMapIndexCreationTask public new void AddMap(Expression, IEnumerable>> map) => base.AddMap(map); @@ -178,12 +178,12 @@ public abstract class ZeroMultiMapIndex : AbstractMultiMapIndexCr } -public abstract class ZeroIndex : AbstractIndexCreationTask, IZeroIndexDefinition +public abstract class FinchIndex : AbstractIndexCreationTask, IFinchIndexDefinition { - public ZeroIndex() { Create(); } + public FinchIndex() { Create(); } protected virtual void Create() { } - public virtual void Setup(IZeroOptions options, IDocumentStore store) { } + public virtual void Setup(IFinchOptions options, IDocumentStore store) { } // AbstractIndexCreationTask public new Expression, IEnumerable>> Map { get => base.Map; set => base.Map = value; } @@ -244,17 +244,17 @@ public abstract class ZeroIndex : AbstractIndexCreatio } -public abstract class ZeroIndex : ZeroIndex +public abstract class FinchIndex : FinchIndex { } -public abstract class ZeroIndex : AbstractIndexCreationTask, IZeroIndexDefinition +public abstract class FinchIndex : AbstractIndexCreationTask, IFinchIndexDefinition { - public ZeroIndex() { Create(); } + public FinchIndex() { Create(); } protected virtual void Create() { } - public virtual void Setup(IZeroOptions options, IDocumentStore store) { } + public virtual void Setup(IFinchOptions options, IDocumentStore store) { } // AbstractIndexCreationTask public new IJsonObject AsJson(object doc) => base.AsJson(doc); @@ -282,7 +282,7 @@ public abstract class ZeroIndex : AbstractIndexCreationTask, IZeroIndexDefinitio } -public interface IZeroIndexDefinition : IAbstractIndexCreationTask +public interface IFinchIndexDefinition : IAbstractIndexCreationTask { - void Setup(IZeroOptions options, IDocumentStore store); + void Setup(IFinchOptions options, IDocumentStore store); } diff --git a/zero.Raven/Indexes/ZeroIndexExtensions.cs b/Finch.Raven/Indexes/FinchIndexExtensions.cs similarity index 63% rename from zero.Raven/Indexes/ZeroIndexExtensions.cs rename to Finch.Raven/Indexes/FinchIndexExtensions.cs index 0555592c..913c0cf5 100644 --- a/zero.Raven/Indexes/ZeroIndexExtensions.cs +++ b/Finch.Raven/Indexes/FinchIndexExtensions.cs @@ -1,14 +1,14 @@ -namespace zero.Raven; +namespace Finch.Raven; -public static class ZeroIndexExtensions +public static class FinchIndexExtensions { - internal static void RunModifiers(this T index, RavenOptions options) where T : IZeroIndexDefinition + internal static void RunModifiers(this T index, RavenOptions options) where T : IFinchIndexDefinition { IEnumerable modifiers = options.Indexes.Modifiers.GetAllForType(index.GetType()); foreach (RavenIndexModifiersOptions.Modifier modifier in modifiers) { - Action action = modifier.Modify.Compile(); + Action action = modifier.Modify.Compile(); action.Invoke(index); } } diff --git a/zero.Raven/Indexes/ZeroTreeHierachyIndex.cs b/Finch.Raven/Indexes/FinchTreeHierachyIndex.cs similarity index 61% rename from zero.Raven/Indexes/ZeroTreeHierachyIndex.cs rename to Finch.Raven/Indexes/FinchTreeHierachyIndex.cs index 255ea19e..6305ae17 100644 --- a/zero.Raven/Indexes/ZeroTreeHierachyIndex.cs +++ b/Finch.Raven/Indexes/FinchTreeHierachyIndex.cs @@ -1,18 +1,18 @@ using Raven.Client.Documents; using Raven.Client.Documents.Indexes; -namespace zero.Raven; +namespace Finch.Raven; -public class ZeroTreeHierarchyIndexResult : ZeroIdEntity, ISupportsDbConventions +public class FinchTreeHierarchyIndexResult : FinchIdEntity, ISupportsDbConventions { public List Path { get; set; } = new List(); } -public abstract class ZeroTreeHierarchyIndex : ZeroIndex where T : ZeroIdEntity, ISupportsTrees +public abstract class FinchTreeHierarchyIndex : FinchIndex where T : FinchIdEntity, ISupportsTrees { protected override void Create() { - Map = items => items.Select(item => new ZeroTreeHierarchyIndexResult + Map = items => items.Select(item => new FinchTreeHierarchyIndexResult { Id = item.Id, Path = Recurse(item, x => LoadDocument(x.ParentId)) diff --git a/zero.Raven/Indexes/RavenIndexExtensions.cs b/Finch.Raven/Indexes/RavenIndexExtensions.cs similarity index 92% rename from zero.Raven/Indexes/RavenIndexExtensions.cs rename to Finch.Raven/Indexes/RavenIndexExtensions.cs index 1447451b..346bca3e 100644 --- a/zero.Raven/Indexes/RavenIndexExtensions.cs +++ b/Finch.Raven/Indexes/RavenIndexExtensions.cs @@ -1,6 +1,6 @@ using Raven.Client.Documents.Indexes; -namespace zero.Raven; +namespace Finch.Raven; public static class RavenIndexExtensions { diff --git a/zero.Raven/Interceptors/Interceptor.cs b/Finch.Raven/Interceptors/Interceptor.cs similarity index 66% rename from zero.Raven/Interceptors/Interceptor.cs rename to Finch.Raven/Interceptors/Interceptor.cs index abdf6b95..6cf23ea6 100644 --- a/zero.Raven/Interceptors/Interceptor.cs +++ b/Finch.Raven/Interceptors/Interceptor.cs @@ -1,7 +1,7 @@ -namespace zero.Raven; +namespace Finch.Raven; -public abstract partial class Interceptor : Interceptor, IInterceptor where T : ZeroIdEntity +public abstract partial class Interceptor : Interceptor, IInterceptor where T : FinchIdEntity { /// public Type ModelType { get; protected set; } @@ -22,51 +22,51 @@ public abstract partial class Interceptor : Interceptor, IInterceptor wher public virtual Task> Creating(InterceptorParameters args, T model) => Task.FromResult>(default); /// - public sealed override async Task> Creating(InterceptorParameters args, ZeroIdEntity model) => Convert(await Creating(args, model as T)); + public sealed override async Task> Creating(InterceptorParameters args, FinchIdEntity model) => Convert(await Creating(args, model as T)); /// public virtual Task> Updating(InterceptorParameters args, T model) => Task.FromResult>(default); /// - public sealed override async Task> Updating(InterceptorParameters args, ZeroIdEntity model) => Convert(await Updating(args, model as T)); + public sealed override async Task> Updating(InterceptorParameters args, FinchIdEntity model) => Convert(await Updating(args, model as T)); /// public virtual Task> Deleting(InterceptorParameters args, T model) => Task.FromResult>(default); /// - public sealed override async Task> Deleting(InterceptorParameters args, ZeroIdEntity model) => Convert(await Deleting(args, model as T)); + public sealed override async Task> Deleting(InterceptorParameters args, FinchIdEntity model) => Convert(await Deleting(args, model as T)); /// public virtual Task Created(InterceptorParameters args, T model) => Task.CompletedTask; /// - public sealed override Task Created(InterceptorParameters args, ZeroIdEntity model) => Created(args, model as T); + public sealed override Task Created(InterceptorParameters args, FinchIdEntity model) => Created(args, model as T); /// public virtual Task Updated(InterceptorParameters args, T model) => Task.CompletedTask; /// - public sealed override Task Updated(InterceptorParameters args, ZeroIdEntity model) => Updated(args, model as T); + public sealed override Task Updated(InterceptorParameters args, FinchIdEntity model) => Updated(args, model as T); /// public virtual Task Deleted(InterceptorParameters args, T model) => Task.CompletedTask; /// - public sealed override Task Deleted(InterceptorParameters args, ZeroIdEntity model) => Deleted(args, model as T); + public sealed override Task Deleted(InterceptorParameters args, FinchIdEntity model) => Deleted(args, model as T); - InterceptorResult Convert(InterceptorResult result) + InterceptorResult Convert(InterceptorResult result) { if (result == default) { return default; } - return new InterceptorResult() + return new InterceptorResult() { Continue = result.Continue, InterceptorHash = result.InterceptorHash, - Result = result.Result != null ? result.Result.ConvertTo(result.Result.Model) : null + Result = result.Result != null ? result.Result.ConvertTo(result.Result.Model) : null }; } } @@ -95,26 +95,26 @@ public abstract partial class Interceptor : IInterceptor public virtual bool CanHandle(InterceptorParameters args, Type modelType) => true; /// - public virtual Task> Creating(InterceptorParameters args, ZeroIdEntity model) => Task.FromResult>(default); + public virtual Task> Creating(InterceptorParameters args, FinchIdEntity model) => Task.FromResult>(default); /// - public virtual Task> Updating(InterceptorParameters args, ZeroIdEntity model) => Task.FromResult>(default); + public virtual Task> Updating(InterceptorParameters args, FinchIdEntity model) => Task.FromResult>(default); /// - public virtual Task> Deleting(InterceptorParameters args, ZeroIdEntity model) => Task.FromResult>(default); + public virtual Task> Deleting(InterceptorParameters args, FinchIdEntity model) => Task.FromResult>(default); /// - public virtual Task Created(InterceptorParameters args, ZeroIdEntity model) => Task.CompletedTask; + public virtual Task Created(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask; /// - public virtual Task Updated(InterceptorParameters args, ZeroIdEntity model) => Task.CompletedTask; + public virtual Task Updated(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask; /// - public virtual Task Deleted(InterceptorParameters args, ZeroIdEntity model) => Task.CompletedTask; + public virtual Task Deleted(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask; } -public interface IInterceptor : IInterceptor where T : ZeroIdEntity +public interface IInterceptor : IInterceptor where T : FinchIdEntity { /// /// Type of the associated model @@ -178,30 +178,30 @@ public interface IInterceptor /// /// Called after an entity has been stored but before the session has saved its changes /// - Task Created(InterceptorParameters args, ZeroIdEntity model); + Task Created(InterceptorParameters args, FinchIdEntity model); /// /// Called before an entity is stored and validated /// - Task> Creating(InterceptorParameters args, ZeroIdEntity model); + Task> Creating(InterceptorParameters args, FinchIdEntity model); /// /// Called after an entity has been deleted but before the session has saved its changes /// - Task Deleted(InterceptorParameters args, ZeroIdEntity model); + Task Deleted(InterceptorParameters args, FinchIdEntity model); /// /// Called before an entity is deleted /// - Task> Deleting(InterceptorParameters args, ZeroIdEntity model); + Task> Deleting(InterceptorParameters args, FinchIdEntity model); /// /// Called after an entity has been updated but before the session has saved its changes /// - Task Updated(InterceptorParameters args, ZeroIdEntity model); + Task Updated(InterceptorParameters args, FinchIdEntity model); /// /// Called before an entity is stored and validated /// - Task> Updating(InterceptorParameters args, ZeroIdEntity model); + Task> Updating(InterceptorParameters args, FinchIdEntity model); } \ No newline at end of file diff --git a/zero.Raven/Interceptors/InterceptorInstruction.cs b/Finch.Raven/Interceptors/InterceptorInstruction.cs similarity index 85% rename from zero.Raven/Interceptors/InterceptorInstruction.cs rename to Finch.Raven/Interceptors/InterceptorInstruction.cs index 4d9a521e..0ef6efa5 100644 --- a/zero.Raven/Interceptors/InterceptorInstruction.cs +++ b/Finch.Raven/Interceptors/InterceptorInstruction.cs @@ -1,8 +1,8 @@ using Microsoft.Extensions.Logging; -namespace zero.Raven; +namespace Finch.Raven; -public class InterceptorInstruction where T : ZeroIdEntity, new() +public class InterceptorInstruction where T : FinchIdEntity, new() { public Guid Guid { get; private set; } @@ -16,9 +16,9 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() public Result Result { get; private set; } - protected IZeroContext Context { get; private set; } + protected IFinchContext Context { get; private set; } - protected IZeroStore Store { get; private set; } + protected IFinchStore Store { get; private set; } protected Lazy> Interceptors { get; private set; } @@ -31,7 +31,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() protected Func InterceptorFilter { get; private set; } = x => true; - internal InterceptorInstruction(IInterceptors interceptors, IZeroStore store, IZeroContext context, Lazy> registrations, ILogger logger, InterceptorRunType runtype, T model, T previousModel = null) + internal InterceptorInstruction(IInterceptors interceptors, IFinchStore store, IFinchContext context, Lazy> registrations, ILogger logger, InterceptorRunType runtype, T model, T previousModel = null) { InterceptorHandler = interceptors; Store = store; @@ -83,7 +83,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() Logger.LogDebug("Run interceptor {interceptor} for {type}:{operation}", interceptor.Name, ModelType, Runtype); - InterceptorResult result = (await HandleBefore(interceptor, parameters)) ?? new(); + InterceptorResult result = (await HandleBefore(interceptor, parameters)) ?? new(); result.InterceptorHash = IdGenerator.Create(32); InterceptorCache.Add(interceptor, parameters); @@ -129,7 +129,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() /// /// Proxy for handling methods on an interceptor /// - protected Task> HandleBefore(IInterceptor interceptor, InterceptorParameters parameters) => Runtype switch + protected Task> HandleBefore(IInterceptor interceptor, InterceptorParameters parameters) => Runtype switch { InterceptorRunType.Create => interceptor.Creating(parameters, Model), InterceptorRunType.Update => interceptor.Updating(parameters, Model), diff --git a/zero.Raven/Interceptors/InterceptorParameters.cs b/Finch.Raven/Interceptors/InterceptorParameters.cs similarity index 88% rename from zero.Raven/Interceptors/InterceptorParameters.cs rename to Finch.Raven/Interceptors/InterceptorParameters.cs index 4b16384d..c1a32798 100644 --- a/zero.Raven/Interceptors/InterceptorParameters.cs +++ b/Finch.Raven/Interceptors/InterceptorParameters.cs @@ -1,16 +1,16 @@ -namespace zero.Raven; +namespace Finch.Raven; public class InterceptorParameters { /// - /// The current zero context + /// The current finch context /// - public IZeroContext Context { get; set; } + public IFinchContext Context { get; set; } /// /// Raven document store /// - public IZeroStore Store { get; set; } + public IFinchStore Store { get; set; } /// /// Access to other interceptor methods diff --git a/zero.Raven/Interceptors/InterceptorResult.cs b/Finch.Raven/Interceptors/InterceptorResult.cs similarity index 95% rename from zero.Raven/Interceptors/InterceptorResult.cs rename to Finch.Raven/Interceptors/InterceptorResult.cs index b6a4a1ba..29c3441f 100644 --- a/zero.Raven/Interceptors/InterceptorResult.cs +++ b/Finch.Raven/Interceptors/InterceptorResult.cs @@ -1,4 +1,4 @@ -namespace zero.Raven; +namespace Finch.Raven; public class InterceptorResult { diff --git a/zero.Raven/Interceptors/InterceptorRunType.cs b/Finch.Raven/Interceptors/InterceptorRunType.cs similarity index 74% rename from zero.Raven/Interceptors/InterceptorRunType.cs rename to Finch.Raven/Interceptors/InterceptorRunType.cs index 292a35ad..16e214b7 100644 --- a/zero.Raven/Interceptors/InterceptorRunType.cs +++ b/Finch.Raven/Interceptors/InterceptorRunType.cs @@ -1,4 +1,4 @@ -namespace zero.Raven; +namespace Finch.Raven; public enum InterceptorRunType { diff --git a/zero.Raven/Interceptors/Interceptors.cs b/Finch.Raven/Interceptors/Interceptors.cs similarity index 55% rename from zero.Raven/Interceptors/Interceptors.cs rename to Finch.Raven/Interceptors/Interceptors.cs index 51606ed3..933954fe 100644 --- a/zero.Raven/Interceptors/Interceptors.cs +++ b/Finch.Raven/Interceptors/Interceptors.cs @@ -1,19 +1,19 @@ using Microsoft.Extensions.Logging; -namespace zero.Raven; +namespace Finch.Raven; public class Interceptors : IInterceptors { - protected IZeroContext Context { get; set; } + protected IFinchContext Context { get; set; } - protected IZeroStore Store { get; set; } + protected IFinchStore Store { get; set; } protected Lazy> Registrations { get; set; } protected ILogger Logger { get; set; } - public Interceptors(IZeroContext context, IZeroStore store, Lazy> registrations, ILogger logger) + public Interceptors(IFinchContext context, IFinchStore store, Lazy> registrations, ILogger logger) { Context = context; Store = store; @@ -23,13 +23,13 @@ public class Interceptors : IInterceptors /// - public InterceptorInstruction ForCreate(T model) where T : ZeroIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Create, model); + public InterceptorInstruction ForCreate(T model) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Create, model); /// - public InterceptorInstruction ForUpdate(T model, T previousModel = null) where T : ZeroIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Update, model, previousModel); + public InterceptorInstruction ForUpdate(T model, T previousModel = null) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Update, model, previousModel); /// - public InterceptorInstruction ForDelete(T model) where T : ZeroIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Delete, model); + public InterceptorInstruction ForDelete(T model) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Delete, model); } @@ -38,15 +38,15 @@ public interface IInterceptors /// /// Instruction which can run interceptors before and after a creating an entity /// - InterceptorInstruction ForCreate(T model) where T : ZeroIdEntity, new(); + InterceptorInstruction ForCreate(T model) where T : FinchIdEntity, new(); /// /// Instruction which can run interceptors before and after updating an entity /// - InterceptorInstruction ForUpdate(T model, T previousModel = null) where T : ZeroIdEntity, new(); + InterceptorInstruction ForUpdate(T model, T previousModel = null) where T : FinchIdEntity, new(); /// /// Instruction which can run interceptors before and after deleting an entity /// - InterceptorInstruction ForDelete(T model) where T : ZeroIdEntity, new(); + InterceptorInstruction ForDelete(T model) where T : FinchIdEntity, new(); } \ No newline at end of file diff --git a/zero.Raven/Operations/RavenOperations.Delete.cs b/Finch.Raven/Operations/RavenOperations.Delete.cs similarity index 88% rename from zero.Raven/Operations/RavenOperations.Delete.cs rename to Finch.Raven/Operations/RavenOperations.Delete.cs index a8fb6ad9..8f31aa67 100644 --- a/zero.Raven/Operations/RavenOperations.Delete.cs +++ b/Finch.Raven/Operations/RavenOperations.Delete.cs @@ -2,17 +2,17 @@ using Raven.Client.Documents.Queries; using Raven.Client; -namespace zero.Raven; +namespace Finch.Raven; public partial class RavenOperations : IRavenOperations { /// - public virtual Task> Delete(T model) where T : ZeroIdEntity, new() + public virtual Task> Delete(T model) where T : FinchIdEntity, new() => Delete(model.Id); /// - public virtual async Task> Delete(string id) where T : ZeroIdEntity, new() + public virtual async Task> Delete(string id) where T : FinchIdEntity, new() { T model = await Load(id); @@ -49,7 +49,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task Purge(string querySuffix = null, Parameters parameters = null) where T : ZeroIdEntity, new() + public virtual async Task Purge(string querySuffix = null, Parameters parameters = null) where T : FinchIdEntity, new() { var collectionName = Store.Raven.Conventions.FindCollectionName(typeof(T)); var operationQuery = new DeleteByQueryOperation(new IndexQuery() diff --git a/zero.Raven/Operations/RavenOperations.Empty.cs b/Finch.Raven/Operations/RavenOperations.Empty.cs similarity index 69% rename from zero.Raven/Operations/RavenOperations.Empty.cs rename to Finch.Raven/Operations/RavenOperations.Empty.cs index 177d2489..965dd651 100644 --- a/zero.Raven/Operations/RavenOperations.Empty.cs +++ b/Finch.Raven/Operations/RavenOperations.Empty.cs @@ -1,14 +1,14 @@ -namespace zero.Raven; +namespace Finch.Raven; public partial class RavenOperations : IRavenOperations { /// - public virtual Task Empty(string flavorAlias = null) where T : ZeroIdEntity, ISupportsFlavors, new() => Empty(flavorAlias); + public virtual Task Empty(string flavorAlias = null) where T : FinchIdEntity, ISupportsFlavors, new() => Empty(flavorAlias); /// public virtual Task Empty(string flavorAlias = null) - where T : ZeroIdEntity, ISupportsFlavors, new() + where T : FinchIdEntity, ISupportsFlavors, new() where TFlavor : T, new() { return Task.FromResult(Flavors.Construct(flavorAlias)); diff --git a/zero.Raven/Operations/RavenOperations.Read.cs b/Finch.Raven/Operations/RavenOperations.Read.cs similarity index 86% rename from zero.Raven/Operations/RavenOperations.Read.cs rename to Finch.Raven/Operations/RavenOperations.Read.cs index f92612d4..323436ee 100644 --- a/zero.Raven/Operations/RavenOperations.Read.cs +++ b/Finch.Raven/Operations/RavenOperations.Read.cs @@ -4,12 +4,12 @@ using Raven.Client.Documents.Linq; using Raven.Client.Documents.Session; using System.Linq.Expressions; -namespace zero.Raven; +namespace Finch.Raven; public partial class RavenOperations : IRavenOperations { /// - public virtual async Task Load(string id, string changeVector = null) where T : ZeroIdEntity, new() + public virtual async Task Load(string id, string changeVector = null) where T : FinchIdEntity, new() { if (id.IsNullOrWhiteSpace()) { @@ -25,7 +25,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> Load(IEnumerable ids) where T : ZeroIdEntity, new() + public virtual async Task> Load(IEnumerable ids) where T : FinchIdEntity, new() { ids = ids.Distinct().ToArray(); @@ -43,7 +43,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> LoadAsList(IEnumerable ids) where T : ZeroIdEntity, new() + public virtual async Task> LoadAsList(IEnumerable ids) where T : FinchIdEntity, new() { ids = ids.Distinct().ToArray(); @@ -64,7 +64,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task Any(Func, IQueryable> querySelector = default) where T : ZeroIdEntity, new() + public virtual async Task Any(Func, IQueryable> querySelector = default) where T : FinchIdEntity, new() { querySelector ??= x => x; return await querySelector(Session.Query()).AnyAsync(); @@ -72,7 +72,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> Load(int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : ZeroIdEntity, new() + public virtual async Task> Load(int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : FinchIdEntity, new() { IRavenQueryable queryable = Session.Query().Statistics(out QueryStatistics statistics); querySelector ??= x => x; @@ -84,7 +84,7 @@ public partial class RavenOperations : IRavenOperations /// public virtual async Task> Load(int pageNumber, int pageSize, Func, IQueryable> querySelector = default) - where T : ZeroIdEntity, new() + where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new() { IRavenQueryable queryable = Session.Query().Statistics(out QueryStatistics statistics); @@ -96,7 +96,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> Load(Func, IQueryable> querySelector) where T : ZeroIdEntity, new() + public virtual async Task> Load(Func, IQueryable> querySelector) where T : FinchIdEntity, new() { IRavenQueryable queryable = Session.Query(); querySelector ??= x => x; @@ -107,7 +107,7 @@ public partial class RavenOperations : IRavenOperations /// public virtual async Task> Load(Func, IQueryable> querySelector) - where T : ZeroIdEntity, new() + where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new() { IRavenQueryable queryable = Session.Query(); @@ -118,7 +118,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> Load(Expression> predicate) where T : ZeroIdEntity, new() + public virtual async Task> Load(Expression> predicate) where T : FinchIdEntity, new() { return await Session.Query().Where(predicate).ToListAsync(); } @@ -126,7 +126,7 @@ public partial class RavenOperations : IRavenOperations /// public virtual async Task> Load(Expression> predicate) - where T : ZeroIdEntity, new() + where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new() { return await Session.Query().Where(predicate).ToListAsync(); @@ -135,8 +135,8 @@ public partial class RavenOperations : IRavenOperations /// public virtual async Task> Load(int pageNumber, int pageSize, Func, IQueryable> querySelector = default) - where T : ZeroIdEntity, new() - where TProjection : ZeroIdEntity, new() + where T : FinchIdEntity, new() + where TProjection : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new() { IRavenQueryable queryable = Session.Query().Statistics(out QueryStatistics statistics); @@ -148,7 +148,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task> LoadAll() where T : ZeroIdEntity, new() + public virtual async Task> LoadAll() where T : FinchIdEntity, new() { List items = new(); @@ -162,7 +162,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async IAsyncEnumerable Stream(Func, IQueryable> expression) where T : ZeroIdEntity, new() + public virtual async IAsyncEnumerable Stream(Func, IQueryable> expression) where T : FinchIdEntity, new() { IRavenQueryable query = Session.Query(); IQueryable queryable = query; @@ -187,7 +187,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual string GetChangeToken(T model) where T : ZeroIdEntity, new() + public virtual string GetChangeToken(T model) where T : FinchIdEntity, new() { string changeVector = Session.Advanced.GetChangeVectorFor(model); return IdGenerator.HashString(changeVector); diff --git a/zero.Raven/Operations/RavenOperations.Tree.cs b/Finch.Raven/Operations/RavenOperations.Tree.cs similarity index 79% rename from zero.Raven/Operations/RavenOperations.Tree.cs rename to Finch.Raven/Operations/RavenOperations.Tree.cs index e04b1c27..c36aa289 100644 --- a/zero.Raven/Operations/RavenOperations.Tree.cs +++ b/Finch.Raven/Operations/RavenOperations.Tree.cs @@ -3,12 +3,12 @@ using Raven.Client.Documents.Indexes; using Raven.Client.Documents.Linq; using Raven.Client.Documents.Session; -namespace zero.Raven; +namespace Finch.Raven; public partial class RavenOperations : IRavenOperations { /// - public virtual Task IsAllowedAsChild(T model, string parentId) where T : ZeroIdEntity, ISupportsTrees, new() + public virtual Task IsAllowedAsChild(T model, string parentId) where T : FinchIdEntity, ISupportsTrees, new() { return Task.FromResult(true); } @@ -16,13 +16,13 @@ public partial class RavenOperations : IRavenOperations /// public async Task GetHierarchy(string id) - where T : ZeroIdEntity, ISupportsTrees, new() - where TIndex : ZeroTreeHierarchyIndex, new() + where T : FinchIdEntity, ISupportsTrees, new() + where TIndex : FinchTreeHierarchyIndex, new() { - ZeroTreeHierarchyIndexResult result = await Session.Query() - .ProjectInto() - .Include(x => x.Path) - .Include(x => x.Id) + FinchTreeHierarchyIndexResult result = await Session.Query() + .ProjectInto() + .Include(x => x.Path) + .Include(x => x.Id) .FirstOrDefaultAsync(x => x.Id == id); if (result == null) @@ -38,7 +38,7 @@ public partial class RavenOperations : IRavenOperations /// - public async Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : ZeroIdEntity, ISupportsTrees, new() + public async Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new() { IRavenQueryable queryable = Session.Query().Where(x => x.ParentId == parentId).Statistics(out QueryStatistics statistics); querySelector ??= x => x.OrderBy(x => x.Sort); @@ -50,7 +50,7 @@ public partial class RavenOperations : IRavenOperations /// public async Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) - where T : ZeroIdEntity, ISupportsTrees, new() + where T : FinchIdEntity, ISupportsTrees, new() where TIndex : AbstractCommonApiForIndexes, new() { IRavenQueryable queryable = Session.Query().Where(x => x.ParentId == parentId).Statistics(out QueryStatistics statistics); @@ -64,7 +64,7 @@ public partial class RavenOperations : IRavenOperations /// - public async Task> Move(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new() + public async Task> Move(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new() { T model = await Load(id); T parent = await Load(newParentId); @@ -86,17 +86,17 @@ public partial class RavenOperations : IRavenOperations /// - public Task> Copy(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new() => Copy(id, newParentId, false, isParentAllowed); + public Task> Copy(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new() => Copy(id, newParentId, false, isParentAllowed); /// - public Task> CopyWithDescendants(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new() => Copy(id, newParentId, true, isParentAllowed); + public Task> CopyWithDescendants(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new() => Copy(id, newParentId, true, isParentAllowed); /// /// Copies an entity (with optional descendants) to a new location /// - protected async Task> Copy(string id, string newParentId, bool includeDescendants, Func> isParentAllowed = null, bool isDescendant = false) where T : ZeroIdEntity, ISupportsTrees, new() + protected async Task> Copy(string id, string newParentId, bool includeDescendants, Func> isParentAllowed = null, bool isDescendant = false) where T : FinchIdEntity, ISupportsTrees, new() { T originalModel = await Load(id); T model = ObjectCopycat.Clone(originalModel); @@ -114,11 +114,11 @@ public partial class RavenOperations : IRavenOperations model.Id = null; model.ParentId = parent?.Id; - if (model is ZeroEntity zeroEntity) + if (model is FinchEntity finchEntity) { - zeroEntity.IsActive = !isDescendant ? false : (originalModel as ZeroEntity).IsActive; - zeroEntity.CreatedDate = DateTime.Now; - zeroEntity.Hash = null; + finchEntity.IsActive = !isDescendant ? false : (originalModel as FinchEntity).IsActive; + finchEntity.CreatedDate = DateTime.Now; + finchEntity.Hash = null; } // check if new parent is allowed @@ -145,7 +145,7 @@ public partial class RavenOperations : IRavenOperations /// - public async Task> DeleteWithDescendants(T model) where T : ZeroIdEntity, ISupportsTrees, new() + public async Task> DeleteWithDescendants(T model) where T : FinchIdEntity, ISupportsTrees, new() { List pages = await GetDescendantsAndSelf(model); @@ -162,7 +162,7 @@ public partial class RavenOperations : IRavenOperations /// /// Get an entity with all its descendants /// - async Task> GetDescendantsAndSelf(T model) where T : ZeroIdEntity, ISupportsTrees, new() + async Task> GetDescendantsAndSelf(T model) where T : FinchIdEntity, ISupportsTrees, new() { List items = new() { model }; diff --git a/zero.Raven/Operations/RavenOperations.Write.cs b/Finch.Raven/Operations/RavenOperations.Write.cs similarity index 90% rename from zero.Raven/Operations/RavenOperations.Write.cs rename to Finch.Raven/Operations/RavenOperations.Write.cs index 8419d1de..2d9bca8d 100644 --- a/zero.Raven/Operations/RavenOperations.Write.cs +++ b/Finch.Raven/Operations/RavenOperations.Write.cs @@ -1,18 +1,18 @@ using FluentValidation.Results; using Rv = Raven.Client; -namespace zero.Raven; +namespace Finch.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 : FinchIdEntity, 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 : FinchIdEntity, 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 : FinchIdEntity, new() { if (model == null) { @@ -91,7 +91,7 @@ public partial class RavenOperations : IRavenOperations /// - public async Task>> Sort(string[] sortedIds) where T : ZeroIdEntity, ISupportsSorting, new() + public async Task>> Sort(string[] sortedIds) where T : FinchIdEntity, ISupportsSorting, new() { Dictionary items = await Load(sortedIds); uint index = 10; @@ -114,7 +114,7 @@ public partial class RavenOperations : IRavenOperations /// - public virtual async Task>> CreateAll(IEnumerable models) where T : ZeroIdEntity, new() + public virtual async Task>> CreateAll(IEnumerable models) where T : FinchIdEntity, new() { using var bulkInsert = Store.Raven.BulkInsert(); diff --git a/zero.Raven/Operations/RavenOperations.cs b/Finch.Raven/Operations/RavenOperations.cs similarity index 69% rename from zero.Raven/Operations/RavenOperations.cs rename to Finch.Raven/Operations/RavenOperations.cs index b34ab55c..dea7fd86 100644 --- a/zero.Raven/Operations/RavenOperations.cs +++ b/Finch.Raven/Operations/RavenOperations.cs @@ -6,7 +6,7 @@ using Raven.Client.Documents.Linq; using System.Linq.Expressions; using System.Security.Claims; -namespace zero.Raven; +namespace Finch.Raven; public partial class RavenOperations : IRavenOperations { @@ -15,7 +15,7 @@ public partial class RavenOperations : IRavenOperations protected record OperationOptions(bool IncludeInactive); - protected IZeroContext Context { get; private set; } + protected IFinchContext Context { get; private set; } protected IInterceptors Interceptors { get; private set; } @@ -23,7 +23,7 @@ public partial class RavenOperations : IRavenOperations protected IServiceProvider Services { get; private set; } - protected IZeroStore Store { get; private set; } + protected IFinchStore Store { get; private set; } protected StoreInterceptorBlocker InterceptorBlocker { get; private set; } @@ -39,7 +39,7 @@ public partial class RavenOperations : IRavenOperations /// - public async Task GenerateId(T model) where T : ZeroIdEntity + public async Task GenerateId(T model) where T : FinchIdEntity { IAsyncDocumentSession session = Session; return await session.Advanced.DocumentStore.Conventions.GenerateDocumentIdAsync(session.Advanced.DocumentStore.Database, model); @@ -54,33 +54,33 @@ public partial class RavenOperations : IRavenOperations /// - public T PrepareForSave(T model) where T : ZeroIdEntity + public T PrepareForSave(T model) where T : FinchIdEntity { // set IDs AutoSetIds(model); - if (model is ZeroEntity zeroModel) + if (model is FinchEntity finchModel) { // get current user string userId = null; //string userId = Context.BackofficeUser.FindFirstValue(Constants.Auth.Claims.UserId).Or(Constants.Auth.SystemUser); // set default properties - if (zeroModel.CreatedDate == default) + if (finchModel.CreatedDate == default) { - zeroModel.CreatedDate = DateTimeOffset.Now; + finchModel.CreatedDate = DateTimeOffset.Now; } - if (zeroModel.CreatedById.IsNullOrEmpty()) + if (finchModel.CreatedById.IsNullOrEmpty()) { - zeroModel.CreatedById = userId; + finchModel.CreatedById = userId; } // update name alias and last modified - zeroModel.Alias = Safenames.Alias(zeroModel.Name); - zeroModel.LastModifiedById = userId; - zeroModel.LastModifiedDate = DateTimeOffset.Now; - zeroModel.CreatedById ??= userId; - zeroModel.Hash ??= IdGenerator.Create(); + finchModel.Alias = Safenames.Alias(finchModel.Name); + finchModel.LastModifiedById = userId; + finchModel.LastModifiedDate = DateTimeOffset.Now; + finchModel.CreatedById ??= userId; + finchModel.Hash ??= IdGenerator.Create(); } return model; @@ -88,9 +88,9 @@ public partial class RavenOperations : IRavenOperations /// - public async Task Validate(T model) where T : ZeroIdEntity, new() + public async Task Validate(T model) where T : FinchIdEntity, new() { - IZeroMergedValidator validator = Services.GetService>(); + IFinchMergedValidator validator = Services.GetService>(); if (validator == null) { @@ -109,10 +109,10 @@ public partial class RavenOperations : IRavenOperations /// - public virtual T WhenActive(T model) where T : ZeroIdEntity, new() + public virtual T WhenActive(T model) where T : FinchIdEntity, new() { return model; // TODO should we really use this? I tried to get data in a custom backend but couldn't because of this - //return model != null && (model is not ZeroEntity || (model as ZeroEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default; + //return model != null && (model is not FinchEntity || (model as FinchEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default; } } @@ -143,20 +143,20 @@ public interface IRavenOperations /// /// Get new instance of an entity (with an optional flavor) /// - Task Empty(string flavorAlias = null) where T : ZeroIdEntity, ISupportsFlavors, new(); + Task Empty(string flavorAlias = null) where T : FinchIdEntity, ISupportsFlavors, new(); /// /// Get new instance of an entity with a specific flavor /// /// Optional alias. If left out the default flavor is used (if configured) Task Empty(string flavorAlias = null) - where T : ZeroIdEntity, ISupportsFlavors, new() + where T : FinchIdEntity, ISupportsFlavors, new() where TFlavor : T, new(); /// /// Generate model Id by using configured document store conventions /// - Task GenerateId(T model) where T : ZeroIdEntity; + Task GenerateId(T model) where T : FinchIdEntity; /// /// Generate values for all properties (incl. nested) which contain the [GenerateId] attribute @@ -164,88 +164,88 @@ public interface IRavenOperations T AutoSetIds(T model); /// - /// Automatically fill base properties of a ZeroEntity + /// Automatically fill base properties of a FinchEntity /// - T PrepareForSave(T model) where T : ZeroIdEntity; + T PrepareForSave(T model) where T : FinchIdEntity; /// /// Check if any items exist in this collection (with optional query) /// - Task Any(Func, IQueryable> querySelector = default) where T : ZeroIdEntity, new(); + Task Any(Func, IQueryable> querySelector = default) where T : FinchIdEntity, new(); /// /// Get an entity by Id /// - Task Load(string id, string changeVector = null) where T : ZeroIdEntity, new(); + Task Load(string id, string changeVector = null) where T : FinchIdEntity, new(); /// /// Get entities by ids /// - Task> Load(IEnumerable ids) where T : ZeroIdEntity, new(); + Task> Load(IEnumerable ids) where T : FinchIdEntity, new(); /// /// Get entities by ids /// - Task> LoadAsList(IEnumerable ids) where T : ZeroIdEntity, new(); + Task> LoadAsList(IEnumerable ids) where T : FinchIdEntity, new(); /// /// Get entities by query /// - Task> Load(int pageNumber, int pageSize, Func, IQueryable> expression = default) where T : ZeroIdEntity, new(); + Task> Load(int pageNumber, int pageSize, Func, IQueryable> expression = default) where T : FinchIdEntity, new(); /// /// Get entities by query (by using the specified index) /// - Task> Load(int pageNumber, int pageSize, Func, IQueryable> expression = default) where T : ZeroIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); + Task> Load(int pageNumber, int pageSize, Func, IQueryable> expression = default) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); /// /// Get entities by query /// - Task> Load(Func, IQueryable> expression) where T : ZeroIdEntity, new(); + Task> Load(Func, IQueryable> expression) where T : FinchIdEntity, new(); /// /// Get entities by query (by using the specified index) /// - Task> Load(Func, IQueryable> expression) where T : ZeroIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); + Task> Load(Func, IQueryable> expression) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); /// /// Get entities by query /// - Task> Load(Expression> predicate) where T : ZeroIdEntity, new(); + Task> Load(Expression> predicate) where T : FinchIdEntity, new(); /// /// Get entities by query (by using the specified index) /// - Task> Load(Expression> predicate) where T : ZeroIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); + Task> Load(Expression> predicate) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); /// /// Get entities by query (by using the specified index) and project into a result /// Task> Load(int pageNumber, int pageSize, Func, IQueryable> querySelector = default) - where T : ZeroIdEntity, new() - where TProjection : ZeroIdEntity, new() + where T : FinchIdEntity, new() + where TProjection : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new(); /// /// Get all entities from this collection. /// Warning: Don't use this method for large collections. Stream the results instead. /// - Task> LoadAll() where T : ZeroIdEntity, new(); + Task> LoadAll() where T : FinchIdEntity, new(); /// /// Stream the collection /// - IAsyncEnumerable Stream(Func, IQueryable> expression) where T : ZeroIdEntity, new(); + IAsyncEnumerable Stream(Func, IQueryable> expression) where T : FinchIdEntity, new(); /// /// Get the change vector for a model /// - string GetChangeToken(T model) where T : ZeroIdEntity, new(); + string GetChangeToken(T model) where T : FinchIdEntity, new(); /// /// Validates an entity /// - Task Validate(T model) where T : ZeroIdEntity, new(); + Task Validate(T model) where T : FinchIdEntity, new(); /// /// Do not run interceptors for create/update/delete operations while this disposable is active @@ -255,73 +255,73 @@ public interface IRavenOperations /// /// Do only return the model when it is set to active or inactive entities are included with IncludeInactive() /// - T WhenActive(T model) where T : ZeroIdEntity, new(); + T WhenActive(T model) where T : FinchIdEntity, new(); /// /// 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 : FinchIdEntity, 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 : FinchIdEntity, new(); /// - Task>> Sort(string[] sortedIds) where T : ZeroIdEntity, ISupportsSorting, new(); + Task>> Sort(string[] sortedIds) where T : FinchIdEntity, ISupportsSorting, new(); /// /// Batch create entities /// - Task>> CreateAll(IEnumerable models) where T : ZeroIdEntity, new(); + Task>> CreateAll(IEnumerable models) where T : FinchIdEntity, new(); /// /// Deletes an entity /// - Task> Delete(T model) where T : ZeroIdEntity, new(); + Task> Delete(T model) where T : FinchIdEntity, new(); /// /// Deletes an entity /// - Task> Delete(string id) where T : ZeroIdEntity, new(); + Task> Delete(string id) where T : FinchIdEntity, new(); /// /// Deletes the whole collection /// - Task Purge(string querySuffix = null, Parameters parameters = null) where T : ZeroIdEntity, new(); + Task Purge(string querySuffix = null, Parameters parameters = null) where T : FinchIdEntity, new(); /// /// Loads all children for an entity /// - Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : ZeroIdEntity, ISupportsTrees, new(); + Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new(); /// /// Get descendants by query (by using the specified index) /// - Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : ZeroIdEntity, ISupportsTrees, new() where TIndex : AbstractCommonApiForIndexes, new(); + Task> LoadChildren(string parentId, int pageNumber, int pageSize, Func, IQueryable> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new() where TIndex : AbstractCommonApiForIndexes, new(); /// /// Get tree hierarchy for an entity /// - Task GetHierarchy(string id) where T : ZeroIdEntity, ISupportsTrees, new() where TIndex : ZeroTreeHierarchyIndex, new(); + Task GetHierarchy(string id) where T : FinchIdEntity, ISupportsTrees, new() where TIndex : FinchTreeHierarchyIndex, new(); /// /// Move an entity to a new parent /// - Task> Move(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new(); + Task> Move(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new(); /// /// Copies an entity to a new location /// - Task> Copy(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new(); + Task> Copy(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new(); /// /// Copies an entity with descendants to a new location /// - Task> CopyWithDescendants(string id, string newParentId, Func> isParentAllowed = null) where T : ZeroIdEntity, ISupportsTrees, new(); + Task> CopyWithDescendants(string id, string newParentId, Func> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new(); /// /// Deletes an entity with all descendents /// - Task> DeleteWithDescendants(T model) where T : ZeroIdEntity, ISupportsTrees, new(); + Task> DeleteWithDescendants(T model) where T : FinchIdEntity, ISupportsTrees, new(); } \ No newline at end of file diff --git a/zero.Raven/Operations/RavenOperationsExtensions.cs b/Finch.Raven/Operations/RavenOperationsExtensions.cs similarity index 63% rename from zero.Raven/Operations/RavenOperationsExtensions.cs rename to Finch.Raven/Operations/RavenOperationsExtensions.cs index 01c18d0a..4711f690 100644 --- a/zero.Raven/Operations/RavenOperationsExtensions.cs +++ b/Finch.Raven/Operations/RavenOperationsExtensions.cs @@ -1,36 +1,36 @@ using Raven.Client.Documents.Linq; using System.Linq.Expressions; -namespace zero.Raven; +namespace Finch.Raven; public static class RavenOperationsExtensions { /// /// Stream the collection /// - public static IAsyncEnumerable Stream(this IRavenOperations ops) where T : ZeroIdEntity, new() => ops.Stream(null); + public static IAsyncEnumerable Stream(this IRavenOperations ops) where T : FinchIdEntity, new() => ops.Stream(null); /// /// Deletes an entity by Id /// - public static async Task> Delete(this IRavenOperations ops, string id) where T : ZeroIdEntity, new() => await ops.Delete(await ops.Load(id)); + public static async Task> Delete(this IRavenOperations ops, string id) where T : FinchIdEntity, new() => await ops.Delete(await ops.Load(id)); /// /// Deletes entities by selector /// - public static async Task Delete(this IRavenOperations ops, Expression> predicate) where T : ZeroIdEntity, new() => await ops.Delete(await ops.Load(predicate)); + public static async Task Delete(this IRavenOperations ops, Expression> predicate) where T : FinchIdEntity, new() => await ops.Delete(await ops.Load(predicate)); /// /// Deletes entities by Id /// - public static async Task Delete(this IRavenOperations ops, IEnumerable ids) where T : ZeroIdEntity, new() => await ops.Delete((await ops.Load(ids)).Select(x => x.Value)); + public static async Task Delete(this IRavenOperations ops, IEnumerable ids) where T : FinchIdEntity, new() => await ops.Delete((await ops.Load(ids)).Select(x => x.Value)); /// /// Deletes entities /// - public static async Task Delete(this IRavenOperations ops, IEnumerable models) where T : ZeroIdEntity, new() + public static async Task Delete(this IRavenOperations ops, IEnumerable models) where T : FinchIdEntity, new() { int successCount = 0; @@ -46,5 +46,5 @@ public static class RavenOperationsExtensions /// /// Deletes an entity by Id with all descendents /// - public static async Task> DeleteWithDescendants(this IRavenOperations ops, string id) where T : ZeroIdEntity, ISupportsTrees, new() => await ops.DeleteWithDescendants(await ops.Load(id)); + public static async Task> DeleteWithDescendants(this IRavenOperations ops, string id) where T : FinchIdEntity, ISupportsTrees, new() => await ops.DeleteWithDescendants(await ops.Load(id)); } \ No newline at end of file diff --git a/zero.Raven/Operations/StoreContext.cs b/Finch.Raven/Operations/StoreContext.cs similarity index 53% rename from zero.Raven/Operations/StoreContext.cs rename to Finch.Raven/Operations/StoreContext.cs index f36e257e..7c4e7156 100644 --- a/zero.Raven/Operations/StoreContext.cs +++ b/Finch.Raven/Operations/StoreContext.cs @@ -1,12 +1,12 @@ -namespace zero.Raven; +namespace Finch.Raven; public class StoreContext { - public IZeroStore Store { get; private set; } + public IFinchStore Store { get; private set; } - public IZeroContext Context { get; private set; } + public IFinchContext Context { get; private set; } - public IZeroOptions Options { get; private set; } + public IFinchOptions Options { get; private set; } public IInterceptors Interceptors { get; private set; } @@ -15,7 +15,7 @@ public class StoreContext public IMessageAggregator Messages { get; private set; } - public StoreContext(IZeroContext context, IZeroStore store, IInterceptors interceptors, IServiceProvider serviceProvider, IMessageAggregator messages) + public StoreContext(IFinchContext context, IFinchStore store, IInterceptors interceptors, IServiceProvider serviceProvider, IMessageAggregator messages) { Store = store; Options = context.Options; diff --git a/zero.Raven/RavenCollectionAttribute.cs b/Finch.Raven/RavenCollectionAttribute.cs similarity index 93% rename from zero.Raven/RavenCollectionAttribute.cs rename to Finch.Raven/RavenCollectionAttribute.cs index c3749e06..06326197 100644 --- a/zero.Raven/RavenCollectionAttribute.cs +++ b/Finch.Raven/RavenCollectionAttribute.cs @@ -1,4 +1,4 @@ -namespace zero.Raven; +namespace Finch.Raven; /// /// This attribute will allow the usage of custom collection names for Raven collections diff --git a/zero.Raven/RavenConstants.cs b/Finch.Raven/RavenConstants.cs similarity index 87% rename from zero.Raven/RavenConstants.cs rename to Finch.Raven/RavenConstants.cs index b0e061c6..d0e4a33d 100644 --- a/zero.Raven/RavenConstants.cs +++ b/Finch.Raven/RavenConstants.cs @@ -1,4 +1,4 @@ -namespace zero.Raven; +namespace Finch.Raven; public static partial class RavenConstants { diff --git a/zero.Raven/RavenDocumentConventionsBuilder.cs b/Finch.Raven/RavenDocumentConventionsBuilder.cs similarity index 88% rename from zero.Raven/RavenDocumentConventionsBuilder.cs rename to Finch.Raven/RavenDocumentConventionsBuilder.cs index 4cb254ff..8a983c84 100644 --- a/zero.Raven/RavenDocumentConventionsBuilder.cs +++ b/Finch.Raven/RavenDocumentConventionsBuilder.cs @@ -4,22 +4,22 @@ using System.Reflection; using System.Text; using Rv = Raven.Client; -namespace zero.Raven; +namespace Finch.Raven; public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder { protected HashSet PolymorphTypes { get; private set; } = new(); - protected Type AcceptsZeroConventionsType { get; set; } = typeof(ISupportsDbConventions); + protected Type AcceptsFinchConventionsType { get; set; } = typeof(ISupportsDbConventions); protected char IdentityPartsSeparator { get; set; } = '.'; - protected IZeroOptions Options { get; private set; } + protected IFinchOptions Options { get; private set; } protected static ConcurrentDictionary CachedTypeCollectionNameMap = new(); - public RavenDocumentConventionsBuilder(IZeroOptions options) + public RavenDocumentConventionsBuilder(IFinchOptions options) { Options = options; } @@ -32,7 +32,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder conventions.IdentityPartsSeparator = IdentityPartsSeparator; conventions.TransformTypeCollectionNameToDocumentIdPrefix = TransformTypeCollectionNameToDocumentIdPrefix; conventions.FindCollectionName = FindCollectionName; - conventions.RegisterAsyncIdConvention((_, entity) => GetDocumentId(conventions, entity)); + conventions.RegisterAsyncIdConvention((_, entity) => GetDocumentId(conventions, entity)); } @@ -80,7 +80,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder } // do not alter non-internal entities - if (!AcceptsZeroConventionsType.IsAssignableFrom(type)) + if (!AcceptsFinchConventionsType.IsAssignableFrom(type)) { return cache(DocumentConventions.DefaultGetCollectionName(type)); } @@ -94,7 +94,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder } // use base interface if available - Type interfaceBaseType = type.GetInterfaces().FirstOrDefault(x => x.IsInterface && AcceptsZeroConventionsType.IsAssignableFrom(x) && x.Name != AcceptsZeroConventionsType.Name); + Type interfaceBaseType = type.GetInterfaces().FirstOrDefault(x => x.IsInterface && AcceptsFinchConventionsType.IsAssignableFrom(x) && x.Name != AcceptsFinchConventionsType.Name); if (interfaceBaseType != null) { diff --git a/zero.Raven/RavenOptions.cs b/Finch.Raven/RavenOptions.cs similarity index 66% rename from zero.Raven/RavenOptions.cs rename to Finch.Raven/RavenOptions.cs index 35991042..dee8884a 100644 --- a/zero.Raven/RavenOptions.cs +++ b/Finch.Raven/RavenOptions.cs @@ -1,7 +1,7 @@ using Raven.Client.Documents; using System.Linq.Expressions; -namespace zero.Raven; +namespace Finch.Raven; public class RavenOptions { @@ -23,9 +23,9 @@ public class RavenIndexesOptions : List { internal Type Type { get; set; } - internal Expression> CreateIndex { get; set; } + internal Expression> CreateIndex { get; set; } - internal Map(Type type, Expression> create) + internal Map(Type type, Expression> create) { Type = type; CreateIndex = create; @@ -35,17 +35,17 @@ public class RavenIndexesOptions : List public RavenIndexModifiersOptions Modifiers { get; private set; } = new(); - public void Add() where T : IZeroIndexDefinition, new() + public void Add() where T : IFinchIndexDefinition, new() { base.Add(new Map(typeof(T), () => new T())); } public void Add(Type indexType) { - base.Add(new Map(indexType, () => (IZeroIndexDefinition)Activator.CreateInstance(indexType))); + base.Add(new Map(indexType, () => (IFinchIndexDefinition)Activator.CreateInstance(indexType))); } - public void Add(T index) where T : IZeroIndexDefinition + public void Add(T index) where T : IFinchIndexDefinition { base.Add(new Map(typeof(T), () => index)); } @@ -59,8 +59,8 @@ public class RavenIndexesOptions : List } public void Replace() - where T : IZeroIndexDefinition, new() - where TReplaceWith : IZeroIndexDefinition, new() + where T : IFinchIndexDefinition, new() + where TReplaceWith : IFinchIndexDefinition, new() { Replace(typeof(T), typeof(TReplaceWith)); } @@ -75,13 +75,13 @@ public class RavenIndexesOptions : List Add(replaceWith); } - public IEnumerable BuildAll(IZeroOptions options, IDocumentStore store) + public IEnumerable BuildAll(IFinchOptions options, IDocumentStore store) { RavenOptions ravenOptions = options.For(); foreach (Map map in this) { - IZeroIndexDefinition index = map.CreateIndex.Compile().Invoke(); + IFinchIndexDefinition index = map.CreateIndex.Compile().Invoke(); index.Setup(options, store); index.RunModifiers(ravenOptions); yield return index; @@ -96,10 +96,10 @@ public class RavenIndexModifiersOptions : List> Modify { get; set; } + public Expression> Modify { get; set; } } - public void Add(Action modify) where T : IZeroIndexDefinition, new() + public void Add(Action modify) where T : IFinchIndexDefinition, new() { Add(new() { @@ -109,7 +109,7 @@ public class RavenIndexModifiersOptions : List GetAllForType() where T : IZeroIndexDefinition, new() => GetAllForType(typeof(T)); + public IEnumerable GetAllForType() where T : IFinchIndexDefinition, new() => GetAllForType(typeof(T)); public IEnumerable GetAllForType(Type type) diff --git a/zero.Raven/Tokens/ZeroTokenProvider.cs b/Finch.Raven/Tokens/FinchTokenProvider.cs similarity index 97% rename from zero.Raven/Tokens/ZeroTokenProvider.cs rename to Finch.Raven/Tokens/FinchTokenProvider.cs index 49b7f8c3..785edb5c 100644 --- a/zero.Raven/Tokens/ZeroTokenProvider.cs +++ b/Finch.Raven/Tokens/FinchTokenProvider.cs @@ -3,18 +3,18 @@ using Raven.Client.Documents.Session; using System.Security.Cryptography; using System.Text; -namespace zero.Raven; +namespace Finch.Raven; -public class ZeroTokenProvider : IZeroTokenProvider +public class FinchTokenProvider : IFinchTokenProvider { readonly char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-".ToCharArray(); readonly RandomNumberGenerator randonNumberGenerator; - protected IZeroStore Store { get; private set; } + protected IFinchStore Store { get; private set; } - public ZeroTokenProvider(IZeroStore store) + public FinchTokenProvider(IFinchStore store) { Store = store; randonNumberGenerator = RandomNumberGenerator.Create(); @@ -246,7 +246,7 @@ public class ZeroTokenProvider : IZeroTokenProvider } -public interface IZeroTokenProvider +public interface IFinchTokenProvider { /// /// Generates a token for a with a specified lifespan. diff --git a/zero.Raven/Tokens/Rfc6238AuthenticationService.cs b/Finch.Raven/Tokens/Rfc6238AuthenticationService.cs similarity index 99% rename from zero.Raven/Tokens/Rfc6238AuthenticationService.cs rename to Finch.Raven/Tokens/Rfc6238AuthenticationService.cs index 5654900e..2ac5b55d 100644 --- a/zero.Raven/Tokens/Rfc6238AuthenticationService.cs +++ b/Finch.Raven/Tokens/Rfc6238AuthenticationService.cs @@ -3,7 +3,7 @@ using System.Net; using System.Security.Cryptography; using System.Text; -namespace zero.Raven; +namespace Finch.Raven; /// /// Replicates the Rfc6238AuthenticationService from ASP.NET Core internals as it isn't part of the public API diff --git a/zero.Raven/Tokens/Token.cs b/Finch.Raven/Tokens/Token.cs similarity index 90% rename from zero.Raven/Tokens/Token.cs rename to Finch.Raven/Tokens/Token.cs index 35c125c1..8a809751 100644 --- a/zero.Raven/Tokens/Token.cs +++ b/Finch.Raven/Tokens/Token.cs @@ -1,4 +1,4 @@ -namespace zero.Raven; +namespace Finch.Raven; [RavenCollection("Tokens")] public class SecurityToken : ISupportsDbConventions diff --git a/zero.Raven/Usings.cs b/Finch.Raven/Usings.cs similarity index 54% rename from zero.Raven/Usings.cs rename to Finch.Raven/Usings.cs index a028d929..a39c98d9 100644 --- a/zero.Raven/Usings.cs +++ b/Finch.Raven/Usings.cs @@ -6,17 +6,17 @@ global using System.Linq; global using System.Threading; global using System.Threading.Tasks; -global using zero.Utils; -global using zero.Configuration; -global using zero.Extensions; -global using zero.FileStorage; -global using zero.Models; -global using zero.Modules; -global using zero.Rendering; -global using zero.Validation; -global using zero.Localization; -global using zero.Context; -global using zero.Communication; +global using Finch.Utils; +global using Finch.Configuration; +global using Finch.Extensions; +global using Finch.FileStorage; +global using Finch.Models; +global using Finch.Modules; +global using Finch.Rendering; +global using Finch.Validation; +global using Finch.Localization; +global using Finch.Context; +global using Finch.Communication; global using Raven.Client.Documents; global using Raven.Client.Documents.Operations; diff --git a/zero.Sqlite/Extensions/SqlExpressionExtensions.cs b/Finch.Sqlite/Extensions/SqlExpressionExtensions.cs similarity index 91% rename from zero.Sqlite/Extensions/SqlExpressionExtensions.cs rename to Finch.Sqlite/Extensions/SqlExpressionExtensions.cs index 93c24977..61b7a104 100644 --- a/zero.Sqlite/Extensions/SqlExpressionExtensions.cs +++ b/Finch.Sqlite/Extensions/SqlExpressionExtensions.cs @@ -2,9 +2,9 @@ using System.Linq; using System.Linq.Expressions; using ServiceStack.OrmLite; -using zero.Extensions; +using Finch.Extensions; -namespace zero.Sqlite; +namespace Finch.Sqlite; public static class SqlExpressionExtensions { @@ -15,7 +15,7 @@ public static class SqlExpressionExtensions if (pageNumber <= 0 || pageSize <= 0) { - throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero"); + throw new NotSupportedException("Both pageNumber and pageSize must be greater than z_ero"); } return source.Skip((pageNumber - 1) * pageSize).Take(pageSize); diff --git a/zero.Sqlite/zero.Sqlite.csproj b/Finch.Sqlite/Finch.Sqlite.csproj similarity index 76% rename from zero.Sqlite/zero.Sqlite.csproj rename to Finch.Sqlite/Finch.Sqlite.csproj index 8d21fac6..a215eab1 100644 --- a/zero.Sqlite/zero.Sqlite.csproj +++ b/Finch.Sqlite/Finch.Sqlite.csproj @@ -1,11 +1,11 @@  - zero.Sqlite + Finch.Sqlite 1.0.0 net8.0;net9.0;net10.0 true - zero.Sqlite + Finch.Sqlite embedded @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/zero.Sqlite/Operations/DbOperations.Delete.cs b/Finch.Sqlite/Operations/DbOperations.Delete.cs similarity index 84% rename from zero.Sqlite/Operations/DbOperations.Delete.cs rename to Finch.Sqlite/Operations/DbOperations.Delete.cs index 1bec7304..7ebe35b2 100644 --- a/zero.Sqlite/Operations/DbOperations.Delete.cs +++ b/Finch.Sqlite/Operations/DbOperations.Delete.cs @@ -2,19 +2,19 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using ServiceStack.OrmLite; -using zero.Models; +using Finch.Models; -namespace zero.Sqlite; +namespace Finch.Sqlite; public partial class DbOperations : IDbOperations { /// - public virtual Task> Delete(T model) where T : ZeroIdEntity, new() + public virtual Task> Delete(T model) where T : FinchIdEntity, new() => Delete(model.Id); /// - public virtual async Task> Delete(string id) where T : ZeroIdEntity, new() + public virtual async Task> Delete(string id) where T : FinchIdEntity, new() { T model = await Load(id); diff --git a/zero.Sqlite/Operations/DbOperations.Read.cs b/Finch.Sqlite/Operations/DbOperations.Read.cs similarity index 79% rename from zero.Sqlite/Operations/DbOperations.Read.cs rename to Finch.Sqlite/Operations/DbOperations.Read.cs index 1bf4bbf3..9025e5df 100644 --- a/zero.Sqlite/Operations/DbOperations.Read.cs +++ b/Finch.Sqlite/Operations/DbOperations.Read.cs @@ -5,16 +5,16 @@ using System.Linq.Expressions; using System.Threading.Tasks; using ServiceStack.OrmLite; using ServiceStack.OrmLite.Dapper; -using zero.Extensions; -using zero.Models; -using zero.Utils; +using Finch.Extensions; +using Finch.Models; +using Finch.Utils; -namespace zero.Sqlite; +namespace Finch.Sqlite; public partial class DbOperations : IDbOperations { /// - public virtual async Task Load(string id, string changeVector = null) where T : ZeroIdEntity, new() + public virtual async Task Load(string id, string changeVector = null) where T : FinchIdEntity, new() { if (id.IsNullOrWhiteSpace()) { @@ -30,7 +30,7 @@ public partial class DbOperations : IDbOperations /// - public virtual async Task> Load(IEnumerable ids) where T : ZeroIdEntity, new() + public virtual async Task> Load(IEnumerable ids) where T : FinchIdEntity, new() { ids = ids.Distinct().ToArray(); @@ -48,7 +48,7 @@ public partial class DbOperations : IDbOperations /// - public virtual async Task> LoadAsList(IEnumerable ids) where T : ZeroIdEntity, new() + public virtual async Task> LoadAsList(IEnumerable ids) where T : FinchIdEntity, new() { ids = ids.Distinct().ToArray(); @@ -69,35 +69,35 @@ public partial class DbOperations : IDbOperations /// - public virtual async Task Any(Expression> querySelector = null) where T : ZeroIdEntity, new() + public virtual async Task Any(Expression> querySelector = null) where T : FinchIdEntity, new() { return await Db.ExistsAsync(querySelector ?? (x => true)); } /// - public virtual async Task> Load(Expression> querySelector) where T : ZeroIdEntity, new() + public virtual async Task> Load(Expression> querySelector) where T : FinchIdEntity, new() { return await Db.SelectAsync(querySelector ?? (x => true)); } /// - public virtual async Task Find(Expression> querySelector) where T : ZeroIdEntity, new() + public virtual async Task Find(Expression> querySelector) where T : FinchIdEntity, new() { return await Db.SingleAsync(querySelector); } /// - public virtual async Task> LoadBySql(Func, SqlExpression> querySelector) where T : ZeroIdEntity, new() + public virtual async Task> LoadBySql(Func, SqlExpression> querySelector) where T : FinchIdEntity, new() { return await Db.SelectAsync(querySelector(Db.From())); } /// - public virtual async Task> LoadAll() where T : ZeroIdEntity, new() + public virtual async Task> LoadAll() where T : FinchIdEntity, new() { return await Db.SelectAsync(x => true); } diff --git a/zero.Sqlite/Operations/DbOperations.Write.cs b/Finch.Sqlite/Operations/DbOperations.Write.cs similarity index 86% rename from zero.Sqlite/Operations/DbOperations.Write.cs rename to Finch.Sqlite/Operations/DbOperations.Write.cs index 337eaa96..0e3c6396 100644 --- a/zero.Sqlite/Operations/DbOperations.Write.cs +++ b/Finch.Sqlite/Operations/DbOperations.Write.cs @@ -5,28 +5,28 @@ using System.Threading.Tasks; using FluentValidation.Results; using Microsoft.Extensions.Logging; using ServiceStack.OrmLite; -using zero.Models; -using zero.Extensions; +using Finch.Models; +using Finch.Extensions; -namespace zero.Sqlite; +namespace Finch.Sqlite; public partial class DbOperations : IDbOperations { /// - public virtual Task> Create(T model, Func> validate = null) where T : ZeroIdEntity, new() => Save(model, validate); + public virtual Task> Create(T model, Func> validate = null) where T : FinchIdEntity, new() => Save(model, validate); /// - public virtual Task> Update(T model, Func> validate = null) where T : ZeroIdEntity, new() => Save(model, validate, true); + public virtual Task> Update(T model, Func> validate = null) where T : FinchIdEntity, new() => Save(model, validate, true); /// - public virtual async Task> CreateOrUpdate(T model, Func> validate = null) where T : ZeroIdEntity, new() + public virtual async Task> CreateOrUpdate(T model, Func> validate = null) where T : FinchIdEntity, new() { bool update = !model.Id.IsNullOrEmpty() && await Any(x => x.Id == model.Id); return await Save(model, validate, update); } /// - protected virtual async Task> Save(T model, Func> validate = null, bool update = false) where T : ZeroIdEntity, new() + protected virtual async Task> Save(T model, Func> validate = null, bool update = false) where T : FinchIdEntity, new() { if (model == null) { @@ -84,9 +84,9 @@ public partial class DbOperations : IDbOperations await Db.SaveAsync(model); string action = update ? "Updated" : "Created"; - if (model is ZeroEntity zeroEntity) + if (model is FinchEntity finchEntity) { - Logger.LogInformation(action + " {id} with name {name}", model.Id, zeroEntity.Name); + Logger.LogInformation(action + " {id} with name {name}", model.Id, finchEntity.Name); } else { @@ -100,7 +100,7 @@ public partial class DbOperations : IDbOperations /// - public virtual async Task Sort(IEnumerable ids) where T : ZeroEntity, new() + public virtual async Task Sort(IEnumerable ids) where T : FinchEntity, new() { List items = await LoadAll(); diff --git a/zero.Sqlite/Operations/DbOperations.cs b/Finch.Sqlite/Operations/DbOperations.cs similarity index 67% rename from zero.Sqlite/Operations/DbOperations.cs rename to Finch.Sqlite/Operations/DbOperations.cs index 5d99fdf8..075712b8 100644 --- a/zero.Sqlite/Operations/DbOperations.cs +++ b/Finch.Sqlite/Operations/DbOperations.cs @@ -8,17 +8,17 @@ using System.Security.Claims; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using ServiceStack.OrmLite; -using zero.Communication; -using zero.Context; -using zero.Models; -using zero.Utils; -using zero.Validation; +using Finch.Communication; +using Finch.Context; +using Finch.Models; +using Finch.Utils; +using Finch.Validation; -namespace zero.Sqlite; +namespace Finch.Sqlite; public partial class DbOperations : IDbOperations { - protected IZeroContext Context { get; private set; } + protected IFinchContext Context { get; private set; } protected FlavorOptions Flavors { get; private set; } @@ -43,14 +43,14 @@ public partial class DbOperations : IDbOperations /// - public bool EnsureTableExists() where T : ZeroIdEntity + public bool EnsureTableExists() where T : FinchIdEntity { return Db.CreateTableIfNotExists(); } /// - public Task GenerateId(T model) where T : ZeroIdEntity + public Task GenerateId(T model) where T : FinchIdEntity { return Task.FromResult(IdGenerator.Create(12)); } @@ -64,35 +64,35 @@ public partial class DbOperations : IDbOperations /// - public T PrepareForSave(T model) where T : ZeroIdEntity + public T PrepareForSave(T model) where T : FinchIdEntity { // set IDs AutoSetIds(model); - if (model is not ZeroEntity zeroModel) + if (model is not FinchEntity finchModel) { return model; } // set default properties - if (zeroModel.CreatedDate == default) + if (finchModel.CreatedDate == default) { - zeroModel.CreatedDate = DateTimeOffset.Now; + finchModel.CreatedDate = DateTimeOffset.Now; } // update name alias and last modified - zeroModel.Alias = Safenames.Alias(zeroModel.Name); - zeroModel.LastModifiedDate = DateTimeOffset.Now; - zeroModel.Hash ??= IdGenerator.Create(); + finchModel.Alias = Safenames.Alias(finchModel.Name); + finchModel.LastModifiedDate = DateTimeOffset.Now; + finchModel.Hash ??= IdGenerator.Create(); return model; } /// - public async Task Validate(T model) where T : ZeroIdEntity, new() + public async Task Validate(T model) where T : FinchIdEntity, new() { - IZeroMergedValidator validator = Services.GetService>(); + IFinchMergedValidator validator = Services.GetService>(); if (validator == null) { @@ -104,10 +104,10 @@ public partial class DbOperations : IDbOperations /// - public virtual T WhenActive(T model) where T : ZeroIdEntity, new() + public virtual T WhenActive(T model) where T : FinchIdEntity, new() { return model; // TODO should we really use this? I tried to get data in a custom backend but couldn't because of this - //return model != null && (model is not ZeroEntity || (model as ZeroEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default; + //return model != null && (model is not FinchEntity || (model as FinchEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default; } } @@ -117,22 +117,22 @@ public interface IDbOperations /// /// Create a table if not existing /// - bool EnsureTableExists() where T : ZeroIdEntity; + bool EnsureTableExists() where T : FinchIdEntity; /// /// Generate model Id by using configured document store conventions /// - Task GenerateId(T model) where T : ZeroIdEntity; + Task GenerateId(T model) where T : FinchIdEntity; /// /// Do only return the model when it is set to active or inactive entities are included with IncludeInactive() /// - T WhenActive(T model) where T : ZeroIdEntity, new(); + T WhenActive(T model) where T : FinchIdEntity, new(); /// /// Validates an entity /// - Task Validate(T model) where T : ZeroIdEntity, new(); + Task Validate(T model) where T : FinchIdEntity, new(); /// /// Generate values for all properties (incl. nested) which contain the [GenerateId] attribute @@ -140,78 +140,78 @@ public interface IDbOperations T AutoSetIds(T model); /// - /// Automatically fill base properties of a ZeroEntity + /// Automatically fill base properties of a FinchEntity /// - T PrepareForSave(T model) where T : ZeroIdEntity; + T PrepareForSave(T model) where T : FinchIdEntity; /// /// Get an entity by Id /// - Task Load(string id, string changeVector = null) where T : ZeroIdEntity, new(); + Task Load(string id, string changeVector = null) where T : FinchIdEntity, new(); /// /// Get entities by ids /// - Task> Load(IEnumerable ids) where T : ZeroIdEntity, new(); + Task> Load(IEnumerable ids) where T : FinchIdEntity, new(); /// /// Get entities by ids /// - Task> LoadAsList(IEnumerable ids) where T : ZeroIdEntity, new(); + Task> LoadAsList(IEnumerable ids) where T : FinchIdEntity, new(); /// /// Check if any items exist in this collection (with optional query) /// - Task Any(Expression> querySelector = null) where T : ZeroIdEntity, new(); + Task Any(Expression> querySelector = null) where T : FinchIdEntity, new(); /// /// Get entities by query /// - Task> Load(Expression> querySelector) where T : ZeroIdEntity, new(); + Task> Load(Expression> querySelector) where T : FinchIdEntity, new(); /// /// Find entity by query /// - Task Find(Expression> querySelector) where T : ZeroIdEntity, new(); + Task Find(Expression> querySelector) where T : FinchIdEntity, new(); /// /// Get entities by sql query /// - Task> LoadBySql(Func, SqlExpression> querySelector) where T : ZeroIdEntity, new(); + Task> LoadBySql(Func, SqlExpression> querySelector) where T : FinchIdEntity, new(); /// /// Get all entities from this collection. /// Warning: Don't use this method for large collections. Stream the results instead. /// - Task> LoadAll() where T : ZeroIdEntity, new(); + Task> LoadAll() where T : FinchIdEntity, new(); /// /// Creates an entity with an optional validator /// - Task> Create(T model, Func> validate = null) where T : ZeroIdEntity, new(); + Task> Create(T model, Func> validate = null) where T : FinchIdEntity, new(); /// /// Updates an entity with an optional validator /// - Task> Update(T model, Func> validate = null) where T : ZeroIdEntity, new(); + Task> Update(T model, Func> validate = null) where T : FinchIdEntity, new(); /// /// Checks if an entity exists (via ID) and creates or updates it afterwards accordingly /// - Task> CreateOrUpdate(T model, Func> validate = null) where T : ZeroIdEntity, new(); + Task> CreateOrUpdate(T model, Func> validate = null) where T : FinchIdEntity, new(); /// /// Updates sorting of all items in a collection based on the given enumerable /// - Task Sort(IEnumerable ids) where T : ZeroEntity, new(); + Task Sort(IEnumerable ids) where T : FinchEntity, new(); /// /// Deletes an entity /// - Task> Delete(T model) where T : ZeroIdEntity, new(); + Task> Delete(T model) where T : FinchIdEntity, new(); /// /// Deletes an entity /// - Task> Delete(string id) where T : ZeroIdEntity, new(); + Task> Delete(string id) where T : FinchIdEntity, new(); } \ No newline at end of file diff --git a/Finch.Sqlite/Operations/IEntityModifiedHandler.cs b/Finch.Sqlite/Operations/IEntityModifiedHandler.cs new file mode 100644 index 00000000..ce3b8f27 --- /dev/null +++ b/Finch.Sqlite/Operations/IEntityModifiedHandler.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using Finch.Communication; +using Finch.Models; + +namespace Finch.Sqlite; + +public interface IEntityModifiedHandler : IHandler +{ + Task Saved(T model, bool update) where T : FinchIdEntity, new() => update ? Updated(model) : Created(model); + Task Created(T model) where T : FinchIdEntity, new(); + Task Updated(T model) where T : FinchIdEntity, new(); + Task Deleted(T model) where T : FinchIdEntity, new(); +} + + +public class EmptyEntityModifiedHandler : IEntityModifiedHandler +{ + public Task Created(T model) where T : FinchIdEntity, new() => Task.CompletedTask; + public Task Updated(T model) where T : FinchIdEntity, new() => Task.CompletedTask; + public Task Deleted(T model) where T : FinchIdEntity, new() => Task.CompletedTask; +} \ No newline at end of file diff --git a/Finch.Sqlite/Operations/StoreContext.cs b/Finch.Sqlite/Operations/StoreContext.cs new file mode 100644 index 00000000..f3643733 --- /dev/null +++ b/Finch.Sqlite/Operations/StoreContext.cs @@ -0,0 +1,26 @@ +using System; +using Finch.Communication; +using Finch.Configuration; +using Finch.Context; + +namespace Finch.Sqlite; + +public class StoreContext +{ + public IFinchContext Context { get; private set; } + + public IFinchOptions Options { get; private set; } + + public IServiceProvider Services { get; private set; } + + public IMessageAggregator Messages { get; private set; } + + + public StoreContext(IFinchContext context, IServiceProvider serviceProvider, IMessageAggregator messages) + { + Options = context.Options; + Context = context; + Services = serviceProvider; + Messages = messages; + } +} \ No newline at end of file diff --git a/zero.Sqlite/SqliteOptions.cs b/Finch.Sqlite/SqliteOptions.cs similarity index 88% rename from zero.Sqlite/SqliteOptions.cs rename to Finch.Sqlite/SqliteOptions.cs index a905a49a..838a74be 100644 --- a/zero.Sqlite/SqliteOptions.cs +++ b/Finch.Sqlite/SqliteOptions.cs @@ -1,7 +1,7 @@ using System; using System.Data; -namespace zero.Sqlite; +namespace Finch.Sqlite; public class SqliteOptions { diff --git a/zero.Sqlite/ZeroSqliteModule.cs b/Finch.Sqlite/ZeroSqliteModule.cs similarity index 75% rename from zero.Sqlite/ZeroSqliteModule.cs rename to Finch.Sqlite/ZeroSqliteModule.cs index be9939b1..971fde63 100644 --- a/zero.Sqlite/ZeroSqliteModule.cs +++ b/Finch.Sqlite/ZeroSqliteModule.cs @@ -4,22 +4,22 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using ServiceStack.Data; using ServiceStack.OrmLite; -using zero.Configuration; -using zero.Models; -using zero.Modules; +using Finch.Configuration; +using Finch.Models; +using Finch.Modules; -namespace zero.Sqlite; +namespace Finch.Sqlite; -public static class ZeroBuilderExtensions +public static class FinchBuilderExtensions { - public static ZeroBuilder AddSqlite(this ZeroBuilder builder) + public static FinchBuilder AddSqlite(this FinchBuilder builder) { - builder.AddModule(); + builder.AddModule(); return builder; } } -internal class ZeroSqliteModule : ZeroModule +internal class FinchSqliteModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { @@ -29,14 +29,14 @@ internal class ZeroSqliteModule : ZeroModule services.AddScoped(); services.AddScoped(); services.AddOptions(); - services.AddOptions().Bind(configuration.GetSection("Zero:Sqlite")); + services.AddOptions().Bind(configuration.GetSection("Finch:Sqlite")); services.ConfigureOptions(); } protected IDbConnectionFactory CreateDbConnectionFactory(IServiceProvider services) { - IZeroOptions options = services.GetService(); + IFinchOptions options = services.GetService(); SqliteOptions sqliteOptions = options.For(); return new OrmLiteConnectionFactory(sqliteOptions.ConnectionString, SqliteDialect.Provider); } @@ -45,7 +45,7 @@ internal class ZeroSqliteModule : ZeroModule protected IDbConnection CreateDbConnection(IServiceProvider services) { IDbConnectionFactory factory = services.GetService(); - IZeroOptions options = services.GetService(); + IFinchOptions options = services.GetService(); SqliteOptions sqliteOptions = options.For(); IDbConnection db = factory.CreateDbConnection(); db.Open(); diff --git a/zero.sln b/Finch.sln similarity index 80% rename from zero.sln rename to Finch.sln index 58c1cce9..f3a2832d 100644 --- a/zero.sln +++ b/Finch.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "zero", "zero\zero.csproj", "{33CD6E46-CD81-42C3-9019-C0EAD557EE99}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Finch", "Finch\Finch.csproj", "{33CD6E46-CD81-42C3-9019-C0EAD557EE99}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "zero.Raven", "zero.Raven\zero.Raven.csproj", "{DC79D7EA-FAA1-4701-9C36-8295CD1C45D0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Finch.Raven", "Finch.Raven\Finch.Raven.csproj", "{DC79D7EA-FAA1-4701-9C36-8295CD1C45D0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zero.Sqlite", "zero.Sqlite\zero.Sqlite.csproj", "{A57D88BC-952F-4311-B474-26FBF0FA957E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Finch.Sqlite", "Finch.Sqlite\Finch.Sqlite.csproj", "{A57D88BC-952F-4311-B474-26FBF0FA957E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/zero/ApplicationBuilderExtensions.cs b/Finch/ApplicationBuilderExtensions.cs similarity index 56% rename from zero/ApplicationBuilderExtensions.cs rename to Finch/ApplicationBuilderExtensions.cs index edb9ef3a..d307b302 100644 --- a/zero/ApplicationBuilderExtensions.cs +++ b/Finch/ApplicationBuilderExtensions.cs @@ -1,12 +1,12 @@ using Microsoft.AspNetCore.Builder; -namespace zero; +namespace Finch; public static class ApplicationBuilderExtensions { - public static IApplicationBuilder UseZero(this IApplicationBuilder app) + public static IApplicationBuilder UseFinch(this IApplicationBuilder app) { - app.UseMiddleware(); + app.UseMiddleware(); app.UseOutputCache(); if (app is WebApplication webApplication) @@ -15,7 +15,7 @@ public static class ApplicationBuilderExtensions webApplication.MapControllers(); } - ZeroBuilder.Modules.Configure(app, null, app.ApplicationServices); + FinchBuilder.Modules.Configure(app, null, app.ApplicationServices); return app; } } diff --git a/zero/Assemblies/AssemblyDiscovery.cs b/Finch/Assemblies/AssemblyDiscovery.cs similarity index 99% rename from zero/Assemblies/AssemblyDiscovery.cs rename to Finch/Assemblies/AssemblyDiscovery.cs index a7914a29..c82a4b7e 100644 --- a/zero/Assemblies/AssemblyDiscovery.cs +++ b/Finch/Assemblies/AssemblyDiscovery.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyModel; using System.Reflection; -namespace zero.Assemblies; +namespace Finch.Assemblies; public class AssemblyDiscovery : IAssemblyDiscovery { diff --git a/zero/Assemblies/AssemblyDiscoveryContext.cs b/Finch/Assemblies/AssemblyDiscoveryContext.cs similarity index 94% rename from zero/Assemblies/AssemblyDiscoveryContext.cs rename to Finch/Assemblies/AssemblyDiscoveryContext.cs index 0e6c0dd4..bcad9ab2 100644 --- a/zero/Assemblies/AssemblyDiscoveryContext.cs +++ b/Finch/Assemblies/AssemblyDiscoveryContext.cs @@ -1,6 +1,6 @@ using System.Reflection; -namespace zero.Assemblies; +namespace Finch.Assemblies; public class AssemblyDiscoveryContext { @@ -23,4 +23,4 @@ public class AssemblyDiscoveryContext EntryAssembly = entryAssembly; EntryAssemblyName = entryAssembly.GetName().Name; } -} +} \ No newline at end of file diff --git a/Finch/Assemblies/FinchAssemblyDiscoveryRule.cs b/Finch/Assemblies/FinchAssemblyDiscoveryRule.cs new file mode 100644 index 00000000..c78f1906 --- /dev/null +++ b/Finch/Assemblies/FinchAssemblyDiscoveryRule.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.DependencyModel; + +namespace Finch.Assemblies; + +public class FinchAssemblyDiscoveryRule : IAssemblyDiscoveryRule +{ + const string FinchPrefix = "Finch."; + + /// + public bool IsValid(RuntimeLibrary library, AssemblyDiscoveryContext context) + { + StringComparison casing = StringComparison.OrdinalIgnoreCase; + // TODO we need to auto-add assemblies and discover their types which have implementations of IFinchPlugin + return library.Name.StartsWith(FinchPrefix, casing) || (context.HasEntryAssembly && library.Name.Contains(context.EntryAssemblyName, casing)); + } +} \ No newline at end of file diff --git a/zero/Assemblies/IAssemblyDiscoveryRule.cs b/Finch/Assemblies/IAssemblyDiscoveryRule.cs similarity index 91% rename from zero/Assemblies/IAssemblyDiscoveryRule.cs rename to Finch/Assemblies/IAssemblyDiscoveryRule.cs index f2b80baf..988fb894 100644 --- a/zero/Assemblies/IAssemblyDiscoveryRule.cs +++ b/Finch/Assemblies/IAssemblyDiscoveryRule.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyModel; -namespace zero.Assemblies; +namespace Finch.Assemblies; public interface IAssemblyDiscoveryRule { diff --git a/zero/Communication/ZeroCommunicationModule.cs b/Finch/Communication/FinchCommunicationModule.cs similarity index 82% rename from zero/Communication/ZeroCommunicationModule.cs rename to Finch/Communication/FinchCommunicationModule.cs index 85396218..c4a35928 100644 --- a/zero/Communication/ZeroCommunicationModule.cs +++ b/Finch/Communication/FinchCommunicationModule.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Communication; +namespace Finch.Communication; -internal class ZeroCommunicationModule : ZeroModule +internal class FinchCommunicationModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { diff --git a/Finch/Communication/Handlers/IHandler.cs b/Finch/Communication/Handlers/IHandler.cs new file mode 100644 index 00000000..93354209 --- /dev/null +++ b/Finch/Communication/Handlers/IHandler.cs @@ -0,0 +1,5 @@ +namespace Finch.Communication; + +public interface IHandler +{ +} diff --git a/zero/Communication/Handlers/IHandlerHolder.cs b/Finch/Communication/Handlers/IHandlerHolder.cs similarity index 94% rename from zero/Communication/Handlers/IHandlerHolder.cs rename to Finch/Communication/Handlers/IHandlerHolder.cs index 096c88ef..f60ad375 100644 --- a/zero/Communication/Handlers/IHandlerHolder.cs +++ b/Finch/Communication/Handlers/IHandlerHolder.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace zero.Communication; +namespace Finch.Communication; public class HandlerHolder : IHandlerHolder { diff --git a/zero/Communication/LazilyResolved.cs b/Finch/Communication/LazilyResolved.cs similarity index 87% rename from zero/Communication/LazilyResolved.cs rename to Finch/Communication/LazilyResolved.cs index 0666dae4..e9ebb223 100644 --- a/zero/Communication/LazilyResolved.cs +++ b/Finch/Communication/LazilyResolved.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace zero.Communication; +namespace Finch.Communication; public class LazilyResolved : Lazy { diff --git a/zero/Communication/Messages/IMessage.cs b/Finch/Communication/Messages/IMessage.cs similarity index 53% rename from zero/Communication/Messages/IMessage.cs rename to Finch/Communication/Messages/IMessage.cs index 4c03d107..3adae38c 100644 --- a/zero/Communication/Messages/IMessage.cs +++ b/Finch/Communication/Messages/IMessage.cs @@ -1,5 +1,5 @@  -namespace zero.Communication; +namespace Finch.Communication; public interface IMessage { diff --git a/zero/Communication/Messages/IMessageHandler.cs b/Finch/Communication/Messages/IMessageHandler.cs similarity index 96% rename from zero/Communication/Messages/IMessageHandler.cs rename to Finch/Communication/Messages/IMessageHandler.cs index a818e1de..4e93782d 100644 --- a/zero/Communication/Messages/IMessageHandler.cs +++ b/Finch/Communication/Messages/IMessageHandler.cs @@ -1,4 +1,4 @@ -namespace zero.Communication; +namespace Finch.Communication; /// /// Indicates a handler that can perform an action when a message of diff --git a/zero/Communication/Messages/MessageAggregator.cs b/Finch/Communication/Messages/MessageAggregator.cs similarity index 98% rename from zero/Communication/Messages/MessageAggregator.cs rename to Finch/Communication/Messages/MessageAggregator.cs index 2ffb3c2a..3a7392c2 100644 --- a/zero/Communication/Messages/MessageAggregator.cs +++ b/Finch/Communication/Messages/MessageAggregator.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; using System.Linq.Expressions; -namespace zero.Communication; +namespace Finch.Communication; public class MessageAggregator : IMessageAggregator { diff --git a/zero/Communication/Messages/MessageSubscription.cs b/Finch/Communication/Messages/MessageSubscription.cs similarity index 98% rename from zero/Communication/Messages/MessageSubscription.cs rename to Finch/Communication/Messages/MessageSubscription.cs index 203825fb..173d8598 100644 --- a/zero/Communication/Messages/MessageSubscription.cs +++ b/Finch/Communication/Messages/MessageSubscription.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using System.Reflection; -namespace zero.Communication; +namespace Finch.Communication; internal class MessageSubscription : IMessageSubscription where TMessage : class, IMessage diff --git a/zero/Configuration/ZeroConfigurationModule.cs b/Finch/Configuration/FinchConfigurationModule.cs similarity index 55% rename from zero/Configuration/ZeroConfigurationModule.cs rename to Finch/Configuration/FinchConfigurationModule.cs index 223c0047..0f3f286d 100644 --- a/zero/Configuration/ZeroConfigurationModule.cs +++ b/Finch/Configuration/FinchConfigurationModule.cs @@ -2,21 +2,21 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace zero.Configuration; +namespace Finch.Configuration; -internal class ZeroConfigurationModule : ZeroModule +internal class FinchConfigurationModule : FinchModule { public override int Order => -1000; public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { - services.AddOptions().Configure((opts, svc) => + services.AddOptions().Configure((opts, svc) => { opts.ServiceProvider = svc; opts.Version = "1.0.0-alpha.1"; opts.TokenExpiration = TimeSpan.FromHours(3); - }).Bind(configuration.GetSection("Zero")); + }).Bind(configuration.GetSection("Finch")); - services.AddTransient(factory => factory.GetService>().Value); + services.AddTransient(factory => factory.GetService>().Value); } } \ No newline at end of file diff --git a/zero/Configuration/ZeroOptions.cs b/Finch/Configuration/FinchOptions.cs similarity index 94% rename from zero/Configuration/ZeroOptions.cs rename to Finch/Configuration/FinchOptions.cs index fcd2028c..c3108082 100644 --- a/zero/Configuration/ZeroOptions.cs +++ b/Finch/Configuration/FinchOptions.cs @@ -2,9 +2,9 @@ using Microsoft.Extensions.Options; using System.Collections.Concurrent; -namespace zero.Configuration; +namespace Finch.Configuration; -public class ZeroOptions : IZeroOptions +public class FinchOptions : IFinchOptions { /// public string Version { get; set; } @@ -41,7 +41,7 @@ public class ZeroOptions : IZeroOptions } -public interface IZeroOptions +public interface IFinchOptions { /// /// The currently active version diff --git a/zero/Configuration/ZeroStartupOptions.cs b/Finch/Configuration/FinchStartupOptions.cs similarity index 67% rename from zero/Configuration/ZeroStartupOptions.cs rename to Finch/Configuration/FinchStartupOptions.cs index cc11bcb8..9fa57835 100644 --- a/zero/Configuration/ZeroStartupOptions.cs +++ b/Finch/Configuration/FinchStartupOptions.cs @@ -1,21 +1,21 @@ using Microsoft.Extensions.DependencyInjection; -namespace zero.Configuration; +namespace Finch.Configuration; -public class ZeroStartupOptions : IZeroStartupOptions +public class FinchStartupOptions : IFinchStartupOptions { public IList AssemblyDiscoveryRules { get; private set; } = new List(); public IMvcBuilder Mvc { get; private set; } - public ZeroStartupOptions(IMvcBuilder mvc) + public FinchStartupOptions(IMvcBuilder mvc) { Mvc = mvc; } } -public interface IZeroStartupOptions +public interface IFinchStartupOptions { IList AssemblyDiscoveryRules { get; } diff --git a/Finch/Configuration/IFinchCollectionOptions.cs b/Finch/Configuration/IFinchCollectionOptions.cs new file mode 100644 index 00000000..389b68a5 --- /dev/null +++ b/Finch/Configuration/IFinchCollectionOptions.cs @@ -0,0 +1,6 @@ +namespace Finch.Configuration; + +public interface IFinchCollectionOptions +{ + +} \ No newline at end of file diff --git a/zero/Configuration/OptionsType.cs b/Finch/Configuration/OptionsType.cs similarity index 93% rename from zero/Configuration/OptionsType.cs rename to Finch/Configuration/OptionsType.cs index 44d73a4a..d0ce5114 100644 --- a/zero/Configuration/OptionsType.cs +++ b/Finch/Configuration/OptionsType.cs @@ -1,6 +1,6 @@ using FluentValidation; -namespace zero.Configuration; +namespace Finch.Configuration; public abstract class OptionsType { diff --git a/zero/Context/ZeroContext.cs b/Finch/Context/FinchContext.cs similarity index 80% rename from zero/Context/ZeroContext.cs rename to Finch/Context/FinchContext.cs index 7e92d0fd..b6a07dd1 100644 --- a/zero/Context/ZeroContext.cs +++ b/Finch/Context/FinchContext.cs @@ -3,18 +3,18 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using System.Security.Claims; -namespace zero.Context; +namespace Finch.Context; -public class ZeroContext : IZeroContext +public class FinchContext : IFinchContext { /// - public IZeroOptions Options { get; protected set; } + public IFinchOptions Options { get; protected set; } /// public IServiceProvider Services { get; private set; } protected ICultureResolver CultureResolver { get; private set; } - protected ILogger Logger { get; private set; } + protected ILogger Logger { get; private set; } protected IHandlerHolder Handler { get; private set; } @@ -26,8 +26,8 @@ public class ZeroContext : IZeroContext bool _resolved = false; - public ZeroContext(IZeroOptions options, IHttpContextAccessor httpContextAccessor, ICultureResolver cultureResolver, - ILogger logger, IHandlerHolder handler, IServiceProvider services) + public FinchContext(IFinchOptions options, IHttpContextAccessor httpContextAccessor, ICultureResolver cultureResolver, + ILogger logger, IHandlerHolder handler, IServiceProvider services) { Options = options; CultureResolver = cultureResolver; @@ -68,12 +68,12 @@ public class ZeroContext : IZeroContext -public interface IZeroContext +public interface IFinchContext { /// - /// Global zero options + /// Global finch options /// - IZeroOptions Options { get; } + IFinchOptions Options { get; } /// /// Service container diff --git a/Finch/Context/FinchContextMiddleware.cs b/Finch/Context/FinchContextMiddleware.cs new file mode 100644 index 00000000..8d66dfa0 --- /dev/null +++ b/Finch/Context/FinchContextMiddleware.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Http; + +namespace Finch.Context +{ + public class FinchContextMiddleware + { + RequestDelegate _next; + + public FinchContextMiddleware(RequestDelegate next) + { + _next = next; + } + + public async Task Invoke(HttpContext httpContext, IFinchContext finchContext) + { + await finchContext.Resolve(httpContext); + await _next(httpContext); + } + } +} diff --git a/zero/Context/ZeroContextModule.cs b/Finch/Context/FinchContextModule.cs similarity index 65% rename from zero/Context/ZeroContextModule.cs rename to Finch/Context/FinchContextModule.cs index 63083b08..af2d3375 100644 --- a/zero/Context/ZeroContextModule.cs +++ b/Finch/Context/FinchContextModule.cs @@ -1,13 +1,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Context; +namespace Finch.Context; -internal class ZeroContextModule : ZeroModule +internal class FinchContextModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { - services.AddScoped(); + services.AddScoped(); services.AddHttpContextAccessor(); } } \ No newline at end of file diff --git a/zero/Extensions/CharExtensions.cs b/Finch/Extensions/CharExtensions.cs similarity index 97% rename from zero/Extensions/CharExtensions.cs rename to Finch/Extensions/CharExtensions.cs index bb9ce986..ec414867 100644 --- a/zero/Extensions/CharExtensions.cs +++ b/Finch/Extensions/CharExtensions.cs @@ -1,4 +1,4 @@ -namespace zero.Extensions; +namespace Finch.Extensions; public static class CharExtensions { diff --git a/zero/Extensions/ColorExtensions.cs b/Finch/Extensions/ColorExtensions.cs similarity index 98% rename from zero/Extensions/ColorExtensions.cs rename to Finch/Extensions/ColorExtensions.cs index 0d35f1d1..efe8d90a 100644 --- a/zero/Extensions/ColorExtensions.cs +++ b/Finch/Extensions/ColorExtensions.cs @@ -1,6 +1,6 @@ using System.Drawing; -namespace zero.Extensions; +namespace Finch.Extensions; public static class ColorExtensions { diff --git a/zero/Extensions/DictionaryExtensions.cs b/Finch/Extensions/DictionaryExtensions.cs similarity index 96% rename from zero/Extensions/DictionaryExtensions.cs rename to Finch/Extensions/DictionaryExtensions.cs index 6575f3a8..e687ca6b 100644 --- a/zero/Extensions/DictionaryExtensions.cs +++ b/Finch/Extensions/DictionaryExtensions.cs @@ -1,4 +1,4 @@ -namespace zero.Extensions; +namespace Finch.Extensions; public static class DictionaryExtensions { diff --git a/zero/Extensions/EnumerableExtensions.cs b/Finch/Extensions/EnumerableExtensions.cs similarity index 92% rename from zero/Extensions/EnumerableExtensions.cs rename to Finch/Extensions/EnumerableExtensions.cs index 9dfd9d9f..a60016ab 100644 --- a/zero/Extensions/EnumerableExtensions.cs +++ b/Finch/Extensions/EnumerableExtensions.cs @@ -1,4 +1,4 @@ -namespace zero.Extensions; +namespace Finch.Extensions; public static class EnumerableExtensions { @@ -9,7 +9,7 @@ public static class EnumerableExtensions if (pageNumber <= 0 || pageSize <= 0) { - throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero"); + throw new NotSupportedException("Both pageNumber and pageSize must be greater than z_ero"); } return source.Skip((pageNumber - 1) * pageSize).Take(pageSize); diff --git a/zero/Extensions/ExpressionExtensions.cs b/Finch/Extensions/ExpressionExtensions.cs similarity index 97% rename from zero/Extensions/ExpressionExtensions.cs rename to Finch/Extensions/ExpressionExtensions.cs index 589fbc25..9ae30b68 100644 --- a/zero/Extensions/ExpressionExtensions.cs +++ b/Finch/Extensions/ExpressionExtensions.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using System.Text; -namespace zero.Extensions; +namespace Finch.Extensions; public static class ExpressionExtensions { diff --git a/zero/Extensions/HttpContextExtensions.cs b/Finch/Extensions/HttpContextExtensions.cs similarity index 98% rename from zero/Extensions/HttpContextExtensions.cs rename to Finch/Extensions/HttpContextExtensions.cs index 314dde5a..0f5e2968 100644 --- a/zero/Extensions/HttpContextExtensions.cs +++ b/Finch/Extensions/HttpContextExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Http; -namespace zero.Extensions; +namespace Finch.Extensions; public static class HttpContextExtensions { diff --git a/zero/Extensions/NumberExtensions.cs b/Finch/Extensions/NumberExtensions.cs similarity index 97% rename from zero/Extensions/NumberExtensions.cs rename to Finch/Extensions/NumberExtensions.cs index 26f13f4f..7849b988 100644 --- a/zero/Extensions/NumberExtensions.cs +++ b/Finch/Extensions/NumberExtensions.cs @@ -1,4 +1,4 @@ -namespace zero.Extensions; +namespace Finch.Extensions; public static class NumberExtensions { diff --git a/zero/Extensions/ObjectExtensions.cs b/Finch/Extensions/ObjectExtensions.cs similarity index 95% rename from zero/Extensions/ObjectExtensions.cs rename to Finch/Extensions/ObjectExtensions.cs index 4f10bbf0..271af136 100644 --- a/zero/Extensions/ObjectExtensions.cs +++ b/Finch/Extensions/ObjectExtensions.cs @@ -1,6 +1,6 @@ //using Newtonsoft.Json; -//namespace zero.Extensions; +//namespace Finch.Extensions; //[Obsolete("we don't want this for every object (use a Utils class instead)")] //public static class ObjectExtensions diff --git a/zero/Extensions/ResultExtensions.cs b/Finch/Extensions/ResultExtensions.cs similarity index 92% rename from zero/Extensions/ResultExtensions.cs rename to Finch/Extensions/ResultExtensions.cs index 2de2c147..a32d88be 100644 --- a/zero/Extensions/ResultExtensions.cs +++ b/Finch/Extensions/ResultExtensions.cs @@ -1,4 +1,4 @@ -namespace zero.Extensions; +namespace Finch.Extensions; public static class ResultExtensions { @@ -31,7 +31,7 @@ public static class ResultExtensions public static Result AddError(this Result origin, string message) { origin.IsSuccess = false; - origin.Errors.Add(new("__zero_no_field", message)); + origin.Errors.Add(new("__finch_no_field", message)); return origin; } diff --git a/zero/Extensions/ServiceCollectionExtensions.cs b/Finch/Extensions/ServiceCollectionExtensions.cs similarity index 98% rename from zero/Extensions/ServiceCollectionExtensions.cs rename to Finch/Extensions/ServiceCollectionExtensions.cs index 9d7e0a5c..06b8f440 100644 --- a/zero/Extensions/ServiceCollectionExtensions.cs +++ b/Finch/Extensions/ServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using System.Reflection; -namespace zero.Extensions; +namespace Finch.Extensions; public static class ServiceCollectionExtensions { @@ -19,7 +19,7 @@ public static class ServiceCollectionExtensions { if (AssemblyDiscovery.Current == null) { - throw new Exception("services.AddAll() can only be run after mvcBuilder.AddZero()"); + throw new Exception("services.AddAll() can only be run after mvcBuilder.AddFinch()"); } // add implementations with generic service types diff --git a/zero/Extensions/StringExtensions.cs b/Finch/Extensions/StringExtensions.cs similarity index 99% rename from zero/Extensions/StringExtensions.cs rename to Finch/Extensions/StringExtensions.cs index b1b23d29..3b3374fb 100644 --- a/zero/Extensions/StringExtensions.cs +++ b/Finch/Extensions/StringExtensions.cs @@ -4,7 +4,7 @@ using System.Text; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Html; -namespace zero.Extensions; +namespace Finch.Extensions; public static class StringExtensions { diff --git a/zero/FileStorage/FileResult.cs b/Finch/FileStorage/FileResult.cs similarity index 82% rename from zero/FileStorage/FileResult.cs rename to Finch/FileStorage/FileResult.cs index d4bcc98b..5a83d7ce 100644 --- a/zero/FileStorage/FileResult.cs +++ b/Finch/FileStorage/FileResult.cs @@ -1,4 +1,4 @@ -namespace zero.FileStorage; +namespace Finch.FileStorage; public class FileResult { diff --git a/zero/FileStorage/FileSizeNotation.cs b/Finch/FileStorage/FileSizeNotation.cs similarity index 93% rename from zero/FileStorage/FileSizeNotation.cs rename to Finch/FileStorage/FileSizeNotation.cs index d85a36e0..ddf21970 100644 --- a/zero/FileStorage/FileSizeNotation.cs +++ b/Finch/FileStorage/FileSizeNotation.cs @@ -1,4 +1,4 @@ -namespace zero.FileStorage; +namespace Finch.FileStorage; public enum FileSizeNotation { diff --git a/zero/FileStorage/FileSystemException.cs b/Finch/FileStorage/FileSystemException.cs similarity index 89% rename from zero/FileStorage/FileSystemException.cs rename to Finch/FileStorage/FileSystemException.cs index fc9d39b0..d8642d0e 100644 --- a/zero/FileStorage/FileSystemException.cs +++ b/Finch/FileStorage/FileSystemException.cs @@ -1,4 +1,4 @@ -namespace zero.FileStorage; +namespace Finch.FileStorage; public class FileSystemException : Exception { diff --git a/Finch/FileStorage/FileSystemOptions.cs b/Finch/FileStorage/FileSystemOptions.cs new file mode 100644 index 00000000..93cd82fe --- /dev/null +++ b/Finch/FileStorage/FileSystemOptions.cs @@ -0,0 +1,6 @@ +namespace Finch.FileStorage; + +public class FileSystemOptions +{ + public string FinchAssetsPath { get; set; } +} \ No newline at end of file diff --git a/zero/FileStorage/ZeroFileStorageModule.cs b/Finch/FileStorage/FinchFileStorageModule.cs similarity index 79% rename from zero/FileStorage/ZeroFileStorageModule.cs rename to Finch/FileStorage/FinchFileStorageModule.cs index f195cdc0..2468e171 100644 --- a/zero/FileStorage/ZeroFileStorageModule.cs +++ b/Finch/FileStorage/FinchFileStorageModule.cs @@ -3,17 +3,17 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace zero.FileStorage; +namespace Finch.FileStorage; -internal class ZeroFileStorageModule : ZeroModule +internal class FinchFileStorageModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddScoped(factory => new Paths(factory.GetService())); - services.AddOptions().Bind(configuration.GetSection("Zero:FileSystem")).Configure(opts => + services.AddOptions().Bind(configuration.GetSection("Finch:FileSystem")).Configure(opts => { - opts.ZeroAssetsPath = "zero"; + opts.FinchAssetsPath = "finch"; }); services.AddSingleton(svc => diff --git a/zero/FileStorage/IFileMeta.cs b/Finch/FileStorage/IFileMeta.cs similarity index 96% rename from zero/FileStorage/IFileMeta.cs rename to Finch/FileStorage/IFileMeta.cs index cd6b49dd..94c4798b 100644 --- a/zero/FileStorage/IFileMeta.cs +++ b/Finch/FileStorage/IFileMeta.cs @@ -1,4 +1,4 @@ -namespace zero.FileStorage; +namespace Finch.FileStorage; public interface IFileMeta { diff --git a/zero/FileStorage/IFileSystem.cs b/Finch/FileStorage/IFileSystem.cs similarity index 98% rename from zero/FileStorage/IFileSystem.cs rename to Finch/FileStorage/IFileSystem.cs index 18e619bc..5e3d185d 100644 --- a/zero/FileStorage/IFileSystem.cs +++ b/Finch/FileStorage/IFileSystem.cs @@ -1,6 +1,6 @@ using System.IO; -namespace zero.FileStorage; +namespace Finch.FileStorage; public interface IFileSystem { diff --git a/zero/FileStorage/Paths.cs b/Finch/FileStorage/Paths.cs similarity index 99% rename from zero/FileStorage/Paths.cs rename to Finch/FileStorage/Paths.cs index 602ab9de..5bae2b5a 100644 --- a/zero/FileStorage/Paths.cs +++ b/Finch/FileStorage/Paths.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.StaticFiles; using System.IO; using System.Text; -namespace zero.FileStorage; +namespace Finch.FileStorage; public class Paths : IPaths { diff --git a/zero/FileStorage/PhysicalFileMeta.cs b/Finch/FileStorage/PhysicalFileMeta.cs similarity index 97% rename from zero/FileStorage/PhysicalFileMeta.cs rename to Finch/FileStorage/PhysicalFileMeta.cs index 6f89c6dc..38eba703 100644 --- a/zero/FileStorage/PhysicalFileMeta.cs +++ b/Finch/FileStorage/PhysicalFileMeta.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.FileProviders; -namespace zero.FileStorage; +namespace Finch.FileStorage; public class PhysicalFileMeta : IFileMeta { diff --git a/zero/FileStorage/PhysicalFileSystem.cs b/Finch/FileStorage/PhysicalFileSystem.cs similarity index 99% rename from zero/FileStorage/PhysicalFileSystem.cs rename to Finch/FileStorage/PhysicalFileSystem.cs index 3981c5ac..556a3f24 100644 --- a/zero/FileStorage/PhysicalFileSystem.cs +++ b/Finch/FileStorage/PhysicalFileSystem.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.FileProviders.Physical; using System.IO; -namespace zero.FileStorage; +namespace Finch.FileStorage; public class PhysicalFileSystem : IFileSystem { diff --git a/zero/FileStorage/WebRootFileSystem.cs b/Finch/FileStorage/WebRootFileSystem.cs similarity index 94% rename from zero/FileStorage/WebRootFileSystem.cs rename to Finch/FileStorage/WebRootFileSystem.cs index 2e09cead..19573d1a 100644 --- a/zero/FileStorage/WebRootFileSystem.cs +++ b/Finch/FileStorage/WebRootFileSystem.cs @@ -1,4 +1,4 @@ -namespace zero.FileStorage; +namespace Finch.FileStorage; public class WebRootFileSystem : PhysicalFileSystem, IWebRootFileSystem { diff --git a/zero/zero.csproj b/Finch/Finch.csproj similarity index 93% rename from zero/zero.csproj rename to Finch/Finch.csproj index c1c3096c..44a2552b 100644 --- a/zero/zero.csproj +++ b/Finch/Finch.csproj @@ -1,11 +1,11 @@ - zero + Finch 1.0.0 net8.0;net9.0;net10.0 true - zero + Finch embedded diff --git a/zero/ZeroBuilder.cs b/Finch/FinchBuilder.cs similarity index 50% rename from zero/ZeroBuilder.cs rename to Finch/FinchBuilder.cs index 27d5f587..e89de9e9 100644 --- a/zero/ZeroBuilder.cs +++ b/Finch/FinchBuilder.cs @@ -2,42 +2,42 @@ using Microsoft.AspNetCore.Antiforgery; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using zero.Logging; -using zero.Mails; -using zero.Metadata; -using zero.Mvc; -using zero.Numbers; -using zero.Routing; -using zero.Security; +using Finch.Logging; +using Finch.Mails; +using Finch.Metadata; +using Finch.Mvc; +using Finch.Numbers; +using Finch.Routing; +using Finch.Security; -namespace zero; +namespace Finch; // TODO maybe use a middleware like Hangfire does: https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.AspNetCore/HangfireEndpointRouteBuilderExtensions.cs -public class ZeroBuilder +public class FinchBuilder { public virtual IServiceCollection Services { get; } public virtual IMvcBuilder Mvc { get; } - internal static ZeroModuleCollection Modules { get; private set; } = new(); + internal static FinchModuleCollection Modules { get; private set; } = new(); readonly IConfiguration _configuration; - readonly IZeroStartupOptions _startupOptions; + readonly IFinchStartupOptions _startupOptions; - public ZeroBuilder(IServiceCollection services, IConfiguration configuration, Action setupAction) + public FinchBuilder(IServiceCollection services, IConfiguration configuration, Action setupAction) { Services = services; Mvc = services.AddMvc(); _configuration = configuration; // create startup options - _startupOptions = new ZeroStartupOptions(Mvc); - _startupOptions.AssemblyDiscoveryRules.Add(new ZeroAssemblyDiscoveryRule()); + _startupOptions = new FinchStartupOptions(Mvc); + _startupOptions.AssemblyDiscoveryRules.Add(new FinchAssemblyDiscoveryRule()); setupAction?.Invoke(_startupOptions); - //string appName = configuration.GetValue("Zero:AppName").Or("zero-app"); + //string appName = configuration.GetValue("Finch:AppName").Or("finch-app"); //services.AddDataProtection();.PersistKeysToRegistry() services.AddControllers(); @@ -46,30 +46,30 @@ public class ZeroBuilder Mvc.AddDataAnnotationsLocalization(); - services.Configure(opts => opts.Cookie.Name = "zero.antiforgery"); + services.Configure(opts => opts.Cookie.Name = "finch.antiforgery"); // adds and discovers additional and built-in assemblies new AssemblyDiscovery(Mvc).Execute(_startupOptions.AssemblyDiscoveryRules); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - //Modules.Add(); - Modules.Add(); - Modules.Add(); - //Modules.Add(); - Modules.Add(); - //Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); - Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + //Modules.Add(); + Modules.Add(); + Modules.Add(); + //Modules.Add(); + Modules.Add(); + //Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); + Modules.Add(); Modules.ConfigureServices(services, configuration); @@ -81,14 +81,14 @@ public class ZeroBuilder /// /// Use specified options /// - public ZeroBuilder WithOptions(Action configureOptions) + public FinchBuilder WithOptions(Action configureOptions) { Services.Configure(configureOptions); return this; } - public ZeroBuilder AddModule(IZeroModule module) + public FinchBuilder AddModule(IFinchModule module) { module.ConfigureServices(Services, _configuration); Modules.Add(module); @@ -96,7 +96,7 @@ public class ZeroBuilder } - public ZeroBuilder AddModule() where T : class, IZeroModule, new() + public FinchBuilder AddModule() where T : class, IFinchModule, new() { T module = new(); module.ConfigureServices(Services, _configuration); diff --git a/zero/Frontend/ZeroViteModule.cs b/Finch/Frontend/FinchViteModule.cs similarity index 92% rename from zero/Frontend/ZeroViteModule.cs rename to Finch/Frontend/FinchViteModule.cs index 284bf4cd..cf5ed710 100644 --- a/zero/Frontend/ZeroViteModule.cs +++ b/Finch/Frontend/FinchViteModule.cs @@ -3,14 +3,14 @@ using ViteProxy; #endif -namespace zero.Frontend; +namespace Finch.Frontend; -public static class ZeroBuilderExtensions +public static class FinchBuilderExtensions { - public static ZeroBuilder AddVite(this ZeroBuilder builder) + public static FinchBuilder AddVite(this FinchBuilder builder) { #if DEBUG - builder.Services.AddViteProxy("Zero:Vite"); + builder.Services.AddViteProxy("Finch:Vite"); #endif return builder; } @@ -27,7 +27,7 @@ public static class ViteProxyApplicationBuilderExtensions } } -// internal class ZeroViteModule : ZeroModule +// internal class FinchViteModule : FinchModule // { // public override int ConfigureOrder { get; } = -1; // diff --git a/zero/Frontend/ViteScriptTagHelper.cs b/Finch/Frontend/ViteScriptTagHelper.cs similarity index 91% rename from zero/Frontend/ViteScriptTagHelper.cs rename to Finch/Frontend/ViteScriptTagHelper.cs index 7753b013..0b87e403 100644 --- a/zero/Frontend/ViteScriptTagHelper.cs +++ b/Finch/Frontend/ViteScriptTagHelper.cs @@ -6,10 +6,10 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -namespace zero.Frontend; +namespace Finch.Frontend; [HtmlTargetElement("app-vitescript", Attributes = "src", TagStructure = TagStructure.NormalOrSelfClosing)] -public class ViteScriptTagHelper(IWebHostEnvironment env, IZeroOptions options) : TagHelper +public class ViteScriptTagHelper(IWebHostEnvironment env, IFinchOptions options) : TagHelper { [HtmlAttributeNotBound] [ViewContext] diff --git a/zero/Identity/ZeroIdentityConstants.cs b/Finch/Identity/FinchIdentityConstants.cs similarity index 83% rename from zero/Identity/ZeroIdentityConstants.cs rename to Finch/Identity/FinchIdentityConstants.cs index 9effa54b..32a956b2 100644 --- a/zero/Identity/ZeroIdentityConstants.cs +++ b/Finch/Identity/FinchIdentityConstants.cs @@ -1,13 +1,13 @@ -namespace zero.Identity; +namespace Finch.Identity; /// /// Represents all the options you can use to configure the cookies middleware used by the identity system. /// -public class ZeroIdentityConstants +public class FinchIdentityConstants { public static class CookieNames { - private const string CookiePrefix = "zero.id"; + private const string CookiePrefix = "Finch.id"; public static readonly string Application = CookiePrefix + ".app"; public static readonly string External = CookiePrefix + ".ext"; @@ -17,9 +17,9 @@ public class ZeroIdentityConstants public static partial class Claims { - private const string ClaimPrefix = "zero.claim"; + private const string ClaimPrefix = "Finch.claim"; - public static readonly string IsZero = ClaimPrefix + ".iszero"; + public static readonly string IsFinch = ClaimPrefix + ".isfinch"; public static readonly string UserId = ClaimPrefix + ".userid"; public static readonly string Username = ClaimPrefix + ".username"; public static readonly string Name = ClaimPrefix + ".name"; diff --git a/zero/Identity/ZeroIdentityExtensions.cs b/Finch/Identity/FinchIdentityExtensions.cs similarity index 78% rename from zero/Identity/ZeroIdentityExtensions.cs rename to Finch/Identity/FinchIdentityExtensions.cs index 84282852..65faafb9 100644 --- a/zero/Identity/ZeroIdentityExtensions.cs +++ b/Finch/Identity/FinchIdentityExtensions.cs @@ -4,9 +4,9 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -namespace zero.Identity; +namespace Finch.Identity; -public static class ZeroIdentityExtensions +public static class FinchIdentityExtensions { // /// Adds the default identity system configuration for the specified User and Role types. @@ -15,10 +15,10 @@ public static class ZeroIdentityExtensions /// The type representing a Role in the system. /// The services available in the application. /// An for creating and configuring the identity system. - public static IdentityBuilder AddZeroIdentity(this IServiceCollection services) - where TUser : ZeroIdentityUser, new() - where TRole : ZeroIdentityRole, new() => - AddZeroIdentity(services, null); + public static IdentityBuilder AddFinchIdentity(this IServiceCollection services) + where TUser : FinchIdentityUser, new() + where TRole : FinchIdentityRole, new() => + AddFinchIdentity(services, null); /// @@ -29,10 +29,10 @@ public static class ZeroIdentityExtensions /// The services available in the application. /// An action to configure the . /// An for creating and configuring the identity system. - public static IdentityBuilder AddZeroIdentity(this IServiceCollection services, + public static IdentityBuilder AddFinchIdentity(this IServiceCollection services, Action setupAction) - where TUser : ZeroIdentityUser, new() - where TRole : ZeroIdentityRole, new() + where TUser : FinchIdentityUser, new() + where TRole : FinchIdentityRole, new() { // Services identity depends on services @@ -53,7 +53,7 @@ public static class ZeroIdentityExtensions o.SlidingExpiration = true; o.ExpireTimeSpan = TimeSpan.FromDays(90); - o.Cookie.Name = ZeroIdentityConstants.CookieNames.Application; + o.Cookie.Name = FinchIdentityConstants.CookieNames.Application; o.Cookie.HttpOnly = true; o.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; o.Cookie.SameSite = SameSiteMode.Lax; @@ -66,12 +66,12 @@ public static class ZeroIdentityExtensions }) .AddCookie(IdentityConstants.ExternalScheme, o => { - o.Cookie.Name = ZeroIdentityConstants.CookieNames.External; + o.Cookie.Name = FinchIdentityConstants.CookieNames.External; o.ExpireTimeSpan = TimeSpan.FromMinutes(5); }) .AddCookie(IdentityConstants.TwoFactorRememberMeScheme, o => { - o.Cookie.Name = ZeroIdentityConstants.CookieNames.TwoFactorRememberMe; + o.Cookie.Name = FinchIdentityConstants.CookieNames.TwoFactorRememberMe; o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = SecurityStampValidator.ValidateAsync @@ -79,7 +79,7 @@ public static class ZeroIdentityExtensions }) .AddCookie(IdentityConstants.TwoFactorUserIdScheme, o => { - o.Cookie.Name = ZeroIdentityConstants.CookieNames.TwoFactorUserId; + o.Cookie.Name = FinchIdentityConstants.CookieNames.TwoFactorUserId; o.ExpireTimeSpan = TimeSpan.FromMinutes(5); }); @@ -105,11 +105,11 @@ public static class ZeroIdentityExtensions services.Configure(opts => { - opts.ClaimsIdentity.UserIdClaimType = ZeroIdentityConstants.Claims.UserId; - opts.ClaimsIdentity.UserNameClaimType = ZeroIdentityConstants.Claims.Username; - opts.ClaimsIdentity.RoleClaimType = ZeroIdentityConstants.Claims.Role; - opts.ClaimsIdentity.SecurityStampClaimType = ZeroIdentityConstants.Claims.SecurityStamp; - opts.ClaimsIdentity.EmailClaimType = ZeroIdentityConstants.Claims.Email; + opts.ClaimsIdentity.UserIdClaimType = FinchIdentityConstants.Claims.UserId; + opts.ClaimsIdentity.UserNameClaimType = FinchIdentityConstants.Claims.Username; + opts.ClaimsIdentity.RoleClaimType = FinchIdentityConstants.Claims.Role; + opts.ClaimsIdentity.SecurityStampClaimType = FinchIdentityConstants.Claims.SecurityStamp; + opts.ClaimsIdentity.EmailClaimType = FinchIdentityConstants.Claims.Email; opts.Password.RequireDigit = false; opts.Password.RequireLowercase = false; @@ -135,7 +135,7 @@ public static class ZeroIdentityExtensions IdentityBuilder builder = new(typeof(TUser), typeof(TRole), services); builder.AddDefaultTokenProviders(); - builder.AddZeroIdentityStores(); + builder.AddFinchIdentityStores(); return builder; } @@ -147,7 +147,7 @@ public static class ZeroIdentityExtensions /// The services available in the application. /// An action to configure the . /// The services. - public static IServiceCollection ConfigureZeroApplicationCookie(this IServiceCollection services, Action configure) + public static IServiceCollection ConfigureFinchApplicationCookie(this IServiceCollection services, Action configure) => services.Configure(IdentityConstants.ApplicationScheme, configure); /// @@ -156,6 +156,6 @@ public static class ZeroIdentityExtensions /// The services available in the application. /// An action to configure the . /// The services. - public static IServiceCollection ConfigureZeroExternalCookie(this IServiceCollection services, Action configure) + public static IServiceCollection ConfigureFinchExternalCookie(this IServiceCollection services, Action configure) => services.Configure(IdentityConstants.ExternalScheme, configure); } \ No newline at end of file diff --git a/zero/Identity/IZeroIdentityStoreDbProvider.cs b/Finch/Identity/FinchIdentityStoreDbProvider.cs similarity index 58% rename from zero/Identity/IZeroIdentityStoreDbProvider.cs rename to Finch/Identity/FinchIdentityStoreDbProvider.cs index 0897a64d..efa2af45 100644 --- a/zero/Identity/IZeroIdentityStoreDbProvider.cs +++ b/Finch/Identity/FinchIdentityStoreDbProvider.cs @@ -1,18 +1,18 @@ using System.Linq.Expressions; -namespace zero.Identity; +namespace Finch.Identity; -public interface IZeroIdentityStoreDbProvider +public interface IFinchIdentityStoreDbProvider { - Task Load(string id, CancellationToken ct = default) where T : ZeroEntity, new(); + Task Load(string id, CancellationToken ct = default) where T : FinchEntity, new(); - Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> FindAll(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task> FindAll(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new(); } \ No newline at end of file diff --git a/zero/Identity/ZeroRoleStore(TRole).cs b/Finch/Identity/FinchRoleStore(TRole).cs similarity index 91% rename from zero/Identity/ZeroRoleStore(TRole).cs rename to Finch/Identity/FinchRoleStore(TRole).cs index 2c0e08c9..095658f2 100644 --- a/zero/Identity/ZeroRoleStore(TRole).cs +++ b/Finch/Identity/FinchRoleStore(TRole).cs @@ -1,21 +1,21 @@ using Microsoft.AspNetCore.Identity; using System.Security.Claims; using Microsoft.AspNetCore.Mvc.ApplicationModels; -using zero.Identity; +using Finch.Identity; -namespace zero.Identity; +namespace Finch.Identity; -public class ZeroRoleStore : +public class FinchRoleStore : IRoleStore, IRoleClaimStore - where TRole : ZeroIdentityRole, new() + where TRole : FinchIdentityRole, new() { protected IdentityErrorDescriber ErrorDescriber { get; private set; } - protected virtual IZeroIdentityStoreDbProvider Db { get; set; } + protected virtual IFinchIdentityStoreDbProvider Db { get; set; } - public ZeroRoleStore(IZeroIdentityStoreDbProvider db, IdentityErrorDescriber describer = null) + public FinchRoleStore(IFinchIdentityStoreDbProvider db, IdentityErrorDescriber describer = null) { Db = db; ErrorDescriber = describer ?? new IdentityErrorDescriber(); @@ -30,7 +30,7 @@ public class ZeroRoleStore : foreach (ResultError error in result.Errors) { string message = error.Message + "(key: " + error.Property + ")"; - errors[index++] = new() { Code = "zero/raven/500", Description = message }; + errors[index++] = new() { Code = "finch/raven/500", Description = message }; } return IdentityResult.Failed(errors); diff --git a/zero/Identity/ZeroUserStore(TUser).cs b/Finch/Identity/FinchUserStore(TUser).cs similarity index 97% rename from zero/Identity/ZeroUserStore(TUser).cs rename to Finch/Identity/FinchUserStore(TUser).cs index a70abc7d..77be3393 100644 --- a/zero/Identity/ZeroUserStore(TUser).cs +++ b/Finch/Identity/FinchUserStore(TUser).cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Identity; using System.Security.Claims; -namespace zero.Identity; +namespace Finch.Identity; -public partial class ZeroUserStore : +public partial class FinchUserStore : IUserStore, IUserEmailStore, IUserLockoutStore, @@ -17,9 +17,9 @@ public partial class ZeroUserStore : IUserTwoFactorStore, IUserTwoFactorRecoveryCodeStore, IUserPhoneNumberStore - where TUser : ZeroIdentityUser, new() + where TUser : FinchIdentityUser, new() { - public ZeroUserStore(IZeroIdentityStoreDbProvider db, IdentityErrorDescriber describer = null) + public FinchUserStore(IFinchIdentityStoreDbProvider db, IdentityErrorDescriber describer = null) { Db = db; ErrorDescriber = describer ?? new IdentityErrorDescriber(); @@ -29,7 +29,7 @@ public partial class ZeroUserStore : protected IdentityErrorDescriber ErrorDescriber { get; private set; } - protected virtual IZeroIdentityStoreDbProvider Db { get; set; } + protected virtual IFinchIdentityStoreDbProvider Db { get; set; } private IdentityResult Fail(Result result) { @@ -39,7 +39,7 @@ public partial class ZeroUserStore : foreach (ResultError error in result.Errors) { string message = error.Message + "(key: " + error.Property + ")"; - errors[index++] = new() { Code = "zero/raven/500", Description = message }; + errors[index++] = new() { Code = "finch/raven/500", Description = message }; } return IdentityResult.Failed(errors); diff --git a/zero/Identity/ZeroUserStore(TUser,TRole).cs b/Finch/Identity/FinchUserStore(TUser,TRole).cs similarity index 80% rename from zero/Identity/ZeroUserStore(TUser,TRole).cs rename to Finch/Identity/FinchUserStore(TUser,TRole).cs index f3a8223a..0b83a225 100644 --- a/zero/Identity/ZeroUserStore(TUser,TRole).cs +++ b/Finch/Identity/FinchUserStore(TUser,TRole).cs @@ -1,14 +1,14 @@ using Microsoft.AspNetCore.Identity; -using zero.Identity; +using Finch.Identity; -namespace zero.Identity; +namespace Finch.Identity; -public partial class ZeroUserStore : ZeroUserStore, +public partial class FinchUserStore : FinchUserStore, IUserRoleStore - where TUser : ZeroIdentityUser, new() - where TRole : ZeroIdentityRole, new() + where TUser : FinchIdentityUser, new() + where TRole : FinchIdentityRole, new() { - public ZeroUserStore(IZeroIdentityStoreDbProvider db) : base(db) { } + public FinchUserStore(IFinchIdentityStoreDbProvider db) : base(db) { } /// diff --git a/zero/Identity/IdentityBuilderExtensions.cs b/Finch/Identity/IdentityBuilderExtensions.cs similarity index 64% rename from zero/Identity/IdentityBuilderExtensions.cs rename to Finch/Identity/IdentityBuilderExtensions.cs index 947ab791..83603fe8 100644 --- a/zero/Identity/IdentityBuilderExtensions.cs +++ b/Finch/Identity/IdentityBuilderExtensions.cs @@ -2,17 +2,17 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -namespace zero.Identity; +namespace Finch.Identity; public static class IdentityBuilderExtensions { /// /// Adds an implementation of identity information stores. /// - public static IdentityBuilder AddZeroIdentityStores(this IdentityBuilder builder) + public static IdentityBuilder AddFinchIdentityStores(this IdentityBuilder builder) { - Type userStoreType = typeof(ZeroUserStore<,>).MakeGenericType(builder.UserType, builder.RoleType); - Type roleStoreType = typeof(ZeroRoleStore<>).MakeGenericType(builder.RoleType); + Type userStoreType = typeof(FinchUserStore<,>).MakeGenericType(builder.UserType, builder.RoleType); + Type roleStoreType = typeof(FinchRoleStore<>).MakeGenericType(builder.RoleType); builder.Services.TryAddScoped(typeof(IUserStore<>).MakeGenericType(builder.UserType), userStoreType); builder.Services.TryAddScoped(typeof(IRoleStore<>).MakeGenericType(builder.RoleType), roleStoreType); diff --git a/zero/Identity/Models/ZeroIdentityRole.cs b/Finch/Identity/Models/FinchIdentityRole.cs similarity index 65% rename from zero/Identity/Models/ZeroIdentityRole.cs rename to Finch/Identity/Models/FinchIdentityRole.cs index 0f78fbbb..0d3f2dd8 100644 --- a/zero/Identity/Models/ZeroIdentityRole.cs +++ b/Finch/Identity/Models/FinchIdentityRole.cs @@ -1,6 +1,6 @@ -namespace zero.Identity; +namespace Finch.Identity; -public abstract class ZeroIdentityRole : ZeroEntity +public abstract class FinchIdentityRole : FinchEntity { /// /// The role's claims, for use in claims-based authentication. diff --git a/zero/Identity/Models/ZeroIdentityUser.cs b/Finch/Identity/Models/FinchIdentityUser.cs similarity index 96% rename from zero/Identity/Models/ZeroIdentityUser.cs rename to Finch/Identity/Models/FinchIdentityUser.cs index 7627fe77..5769e20e 100644 --- a/zero/Identity/Models/ZeroIdentityUser.cs +++ b/Finch/Identity/Models/FinchIdentityUser.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Identity; -namespace zero.Identity; +namespace Finch.Identity; -public abstract class ZeroIdentityUser : ZeroEntity +public abstract class FinchIdentityUser : FinchEntity { /// /// Optional username (can also be used as login when configured) diff --git a/zero/Identity/Models/TwoFactorKey.cs b/Finch/Identity/Models/TwoFactorKey.cs similarity index 95% rename from zero/Identity/Models/TwoFactorKey.cs rename to Finch/Identity/Models/TwoFactorKey.cs index dad1d969..7362202d 100644 --- a/zero/Identity/Models/TwoFactorKey.cs +++ b/Finch/Identity/Models/TwoFactorKey.cs @@ -1,7 +1,7 @@ using System.Security.Claims; -using zero.Rendering.QrCode; +using Finch.Rendering.QrCode; -namespace zero.Identity; +namespace Finch.Identity; public class TwoFactorKey { diff --git a/zero/Identity/Models/UserClaim.cs b/Finch/Identity/Models/UserClaim.cs similarity index 96% rename from zero/Identity/Models/UserClaim.cs rename to Finch/Identity/Models/UserClaim.cs index ed3aad62..9c1d33cd 100644 --- a/zero/Identity/Models/UserClaim.cs +++ b/Finch/Identity/Models/UserClaim.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace zero.Identity; +namespace Finch.Identity; public class UserClaim { diff --git a/zero/Identity/Models/UserClaimComparer.cs b/Finch/Identity/Models/UserClaimComparer.cs similarity index 93% rename from zero/Identity/Models/UserClaimComparer.cs rename to Finch/Identity/Models/UserClaimComparer.cs index 8765ff60..8f6815e6 100644 --- a/zero/Identity/Models/UserClaimComparer.cs +++ b/Finch/Identity/Models/UserClaimComparer.cs @@ -1,4 +1,4 @@ -namespace zero.Identity; +namespace Finch.Identity; public class UserClaimComparer : IEqualityComparer { diff --git a/zero/Identity/Models/UserExternalLogin.cs b/Finch/Identity/Models/UserExternalLogin.cs similarity index 96% rename from zero/Identity/Models/UserExternalLogin.cs rename to Finch/Identity/Models/UserExternalLogin.cs index 95e8ca5d..cbf1010a 100644 --- a/zero/Identity/Models/UserExternalLogin.cs +++ b/Finch/Identity/Models/UserExternalLogin.cs @@ -1,7 +1,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Identity; -namespace zero.Identity; +namespace Finch.Identity; public class UserExternalLogin { diff --git a/zero/Identity/Models/UserToken.cs b/Finch/Identity/Models/UserToken.cs similarity index 94% rename from zero/Identity/Models/UserToken.cs rename to Finch/Identity/Models/UserToken.cs index 7114cba8..631c5be8 100644 --- a/zero/Identity/Models/UserToken.cs +++ b/Finch/Identity/Models/UserToken.cs @@ -1,7 +1,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Identity; -namespace zero.Identity; +namespace Finch.Identity; public class UserToken { diff --git a/zero/Identity/UserManagerExtensions.cs b/Finch/Identity/UserManagerExtensions.cs similarity index 98% rename from zero/Identity/UserManagerExtensions.cs rename to Finch/Identity/UserManagerExtensions.cs index 9caff0c1..a8a06c80 100644 --- a/zero/Identity/UserManagerExtensions.cs +++ b/Finch/Identity/UserManagerExtensions.cs @@ -4,9 +4,9 @@ using System.Text.Encodings.Web; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using zero.Rendering.QrCode; +using Finch.Rendering.QrCode; -namespace zero.Identity; +namespace Finch.Identity; public static class UserManagerExtensions { diff --git a/zero/Localization/ConfigurationLocalizer.cs b/Finch/Localization/ConfigurationLocalizer.cs similarity index 86% rename from zero/Localization/ConfigurationLocalizer.cs rename to Finch/Localization/ConfigurationLocalizer.cs index d749fc5e..94e98315 100644 --- a/zero/Localization/ConfigurationLocalizer.cs +++ b/Finch/Localization/ConfigurationLocalizer.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Options; using System.Collections.Concurrent; -namespace zero.Localization; +namespace Finch.Localization; public class ConfigurationLocalizer : Localizer { @@ -11,7 +11,7 @@ public class ConfigurationLocalizer : Localizer public ConfigurationLocalizer(IConfiguration configuration, ICultureResolver cultureResolver, IOptionsMonitor options) : base(cultureResolver) { - IConfigurationSection section = configuration.GetSection($"Zero:Localization:{LanguageCode}"); + IConfigurationSection section = configuration.GetSection($"Finch:Localization:{LanguageCode}"); if (section != null) { diff --git a/zero/Localization/CultureChangeMessage.cs b/Finch/Localization/CultureChangeMessage.cs similarity index 80% rename from zero/Localization/CultureChangeMessage.cs rename to Finch/Localization/CultureChangeMessage.cs index 5f73d7f6..7fb0bc85 100644 --- a/zero/Localization/CultureChangeMessage.cs +++ b/Finch/Localization/CultureChangeMessage.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace zero.Localization; +namespace Finch.Localization; public class CultureChangeMessage : IMessage { diff --git a/zero/Localization/CultureResolver.cs b/Finch/Localization/CultureResolver.cs similarity index 94% rename from zero/Localization/CultureResolver.cs rename to Finch/Localization/CultureResolver.cs index 8e98767b..48fb2abf 100644 --- a/zero/Localization/CultureResolver.cs +++ b/Finch/Localization/CultureResolver.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using System.Globalization; using System.Linq.Expressions; -namespace zero.Localization; +namespace Finch.Localization; public class CultureResolver : ICultureResolver { @@ -23,7 +23,7 @@ public class CultureResolver : ICultureResolver /// - public Task Resolve(IZeroContext context) + public Task Resolve(IFinchContext context) { if (!TryConvert(context.Options.Language, out CultureInfo culture)) { @@ -96,7 +96,7 @@ public interface ICultureResolver /// Resolves the current application from either the backoffice user (in case it is backoffice request) /// or the domain (in case it is frontend request). /// - Task Resolve(IZeroContext context); + Task Resolve(IFinchContext context); /// /// Tries to convert an ISO code to a culture diff --git a/zero/Localization/CultureService.cs b/Finch/Localization/CultureService.cs similarity index 96% rename from zero/Localization/CultureService.cs rename to Finch/Localization/CultureService.cs index b1a111a4..e7250713 100644 --- a/zero/Localization/CultureService.cs +++ b/Finch/Localization/CultureService.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace zero.Localization; +namespace Finch.Localization; public class CultureService : ICultureService { diff --git a/zero/Localization/ZeroLocalizationModule.cs b/Finch/Localization/FinchLocalizationModule.cs similarity index 90% rename from zero/Localization/ZeroLocalizationModule.cs rename to Finch/Localization/FinchLocalizationModule.cs index f4987fc5..10fcebe0 100644 --- a/zero/Localization/ZeroLocalizationModule.cs +++ b/Finch/Localization/FinchLocalizationModule.cs @@ -5,9 +5,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; -namespace zero.Localization; +namespace Finch.Localization; -internal class ZeroLocalizationModule : ZeroModule +internal class FinchLocalizationModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { @@ -26,7 +26,7 @@ internal class ZeroLocalizationModule : ZeroModule services.AddLocalization(); - services.AddOptions().Bind(configuration.GetSection("Zero:Localization")).Configure(opts => + services.AddOptions().Bind(configuration.GetSection("Finch:Localization")).Configure(opts => { opts.FilePath = "Config/texts.json"; }); diff --git a/zero/Localization/LocalizationOptions.cs b/Finch/Localization/LocalizationOptions.cs similarity index 69% rename from zero/Localization/LocalizationOptions.cs rename to Finch/Localization/LocalizationOptions.cs index 1302660c..73995c48 100644 --- a/zero/Localization/LocalizationOptions.cs +++ b/Finch/Localization/LocalizationOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Localization; +namespace Finch.Localization; public class LocalizationOptions { diff --git a/zero/Localization/LocalizeAttribute.cs b/Finch/Localization/LocalizeAttribute.cs similarity index 87% rename from zero/Localization/LocalizeAttribute.cs rename to Finch/Localization/LocalizeAttribute.cs index aa8c9de2..6438578c 100644 --- a/zero/Localization/LocalizeAttribute.cs +++ b/Finch/Localization/LocalizeAttribute.cs @@ -1,4 +1,4 @@ -namespace zero.Localization; +namespace Finch.Localization; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field, AllowMultiple = false)] public class LocalizeAttribute : Attribute diff --git a/zero/Localization/Localizer.cs b/Finch/Localization/Localizer.cs similarity index 99% rename from zero/Localization/Localizer.cs rename to Finch/Localization/Localizer.cs index 4757e66d..7f5e0b1c 100644 --- a/zero/Localization/Localizer.cs +++ b/Finch/Localization/Localizer.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Reflection; -namespace zero.Localization; +namespace Finch.Localization; public abstract class Localizer : ILocalizer { diff --git a/zero/Localization/LocalizerExtensions.cs b/Finch/Localization/LocalizerExtensions.cs similarity index 96% rename from zero/Localization/LocalizerExtensions.cs rename to Finch/Localization/LocalizerExtensions.cs index c5e35150..b721f1d1 100644 --- a/zero/Localization/LocalizerExtensions.cs +++ b/Finch/Localization/LocalizerExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Html; -namespace zero.Localization; +namespace Finch.Localization; public static class LocalizerExtensions { diff --git a/zero/Localization/Models/Culture.cs b/Finch/Localization/Models/Culture.cs similarity index 74% rename from zero/Localization/Models/Culture.cs rename to Finch/Localization/Models/Culture.cs index eed5ff88..cd5cd990 100644 --- a/zero/Localization/Models/Culture.cs +++ b/Finch/Localization/Models/Culture.cs @@ -1,4 +1,4 @@ -namespace zero.Localization; +namespace Finch.Localization; public class Culture { diff --git a/zero/Localization/Models/Translation.cs b/Finch/Localization/Models/Translation.cs similarity index 92% rename from zero/Localization/Models/Translation.cs rename to Finch/Localization/Models/Translation.cs index 3fc3849e..aa5a95fc 100644 --- a/zero/Localization/Models/Translation.cs +++ b/Finch/Localization/Models/Translation.cs @@ -1,4 +1,4 @@ -namespace zero.Localization; +namespace Finch.Localization; public record Translation { diff --git a/zero/Localization/StringLocalizer.cs b/Finch/Localization/StringLocalizer.cs similarity index 98% rename from zero/Localization/StringLocalizer.cs rename to Finch/Localization/StringLocalizer.cs index 81bc3112..6847a485 100644 --- a/zero/Localization/StringLocalizer.cs +++ b/Finch/Localization/StringLocalizer.cs @@ -1,7 +1,7 @@ using System.Globalization; using Microsoft.Extensions.Localization; -namespace zero.Localization; +namespace Finch.Localization; public class StringLocalizer : StringLocalizer, IStringLocalizer { diff --git a/zero/Logging/ZeroLoggingModule.cs b/Finch/Logging/FinchLoggingModule.cs similarity index 80% rename from zero/Logging/ZeroLoggingModule.cs rename to Finch/Logging/FinchLoggingModule.cs index 637d1894..4086c802 100644 --- a/zero/Logging/ZeroLoggingModule.cs +++ b/Finch/Logging/FinchLoggingModule.cs @@ -2,9 +2,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace zero.Logging; +namespace Finch.Logging; -public class ZeroLoggingModule : ZeroModule +public class FinchLoggingModule : FinchModule { public override int Order { get; } = -100; @@ -14,13 +14,13 @@ public class ZeroLoggingModule : ZeroModule services.AddLogging(builder => { // get seq configuration - IConfigurationSection seqConfig = configuration.GetSection("Zero:Seq"); - ZeroSeqOptions seqOptions = seqConfig.Get(); + IConfigurationSection seqConfig = configuration.GetSection("Finch:Seq"); + FinchSeqOptions seqOptions = seqConfig.Get(); // default level builder.SetMinimumLevel(seqOptions.MinimumLevel); - // apply log level overrides from zero + // apply log level overrides from finch foreach (KeyValuePair levelOverride in seqOptions.LevelOverrides) { builder.AddFilter(levelOverride.Key, levelOverride.Value); diff --git a/zero/Logging/ZeroSeqOptions.cs b/Finch/Logging/FinchSeqOptions.cs similarity index 93% rename from zero/Logging/ZeroSeqOptions.cs rename to Finch/Logging/FinchSeqOptions.cs index 09abe036..82d7ea1d 100644 --- a/zero/Logging/ZeroSeqOptions.cs +++ b/Finch/Logging/FinchSeqOptions.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Logging; using Seq.Extensions.Logging; -namespace zero.Logging; +namespace Finch.Logging; -public class ZeroSeqOptions +public class FinchSeqOptions { /// /// URL to the Seq server diff --git a/zero/Logging/LogLevelOverrides.cs b/Finch/Logging/LogLevelOverrides.cs similarity index 71% rename from zero/Logging/LogLevelOverrides.cs rename to Finch/Logging/LogLevelOverrides.cs index b1914f5e..1cb1f27f 100644 --- a/zero/Logging/LogLevelOverrides.cs +++ b/Finch/Logging/LogLevelOverrides.cs @@ -1,23 +1,23 @@ using System.Reflection; using Microsoft.Extensions.Logging; -namespace zero.Logging; +namespace Finch.Logging; public class LogLevelOverrides : Dictionary { public LogLevelOverrides()//IHostEnvironment env) { - this["zero"] = LogLevel.Debug; - this["zero.Routing"] = LogLevel.Debug; + this["finch"] = LogLevel.Debug; + this["Finch.Routing"] = LogLevel.Debug; // if (env.IsDevelopment()) // { - // this["zero"] = LogLevel.Debug; - // this["zero.Routing"] = LogLevel.Debug; + // this["finch"] = LogLevel.Debug; + // this["Finch.Routing"] = LogLevel.Debug; // } // else // { - // this["zero"] = LogLevel.Debug; + // this["finch"] = LogLevel.Debug; // } this["SixLabors"] = LogLevel.Warning; diff --git a/zero/Mails/FileMailDispatcher.cs b/Finch/Mails/FileMailDispatcher.cs similarity index 98% rename from zero/Mails/FileMailDispatcher.cs rename to Finch/Mails/FileMailDispatcher.cs index de3187b8..51d0cd25 100644 --- a/zero/Mails/FileMailDispatcher.cs +++ b/Finch/Mails/FileMailDispatcher.cs @@ -1,7 +1,7 @@ //using System.IO; //using System.Text; -//namespace zero.Mails; +//namespace Finch.Mails; ///// ///// Default implementation of an IMailSender which sends the mail a flat file diff --git a/zero/Mails/ZeroMailModule.cs b/Finch/Mails/FinchMailModule.cs similarity index 83% rename from zero/Mails/ZeroMailModule.cs rename to Finch/Mails/FinchMailModule.cs index fe5e4140..00b660c4 100644 --- a/zero/Mails/ZeroMailModule.cs +++ b/Finch/Mails/FinchMailModule.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Mails; +namespace Finch.Mails; -internal class ZeroMailModule : ZeroModule +internal class FinchMailModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { @@ -11,7 +11,7 @@ internal class ZeroMailModule : ZeroModule //services.AddScoped(); services.AddScoped(); - services.AddOptions().Bind(configuration.GetSection("Zero:Mails")).Configure(opts => + services.AddOptions().Bind(configuration.GetSection("Finch:Mails")).Configure(opts => { opts.BuildViewPath = mail => $"~/Mails/{mail.ViewKey.Replace('.', '/')}.cshtml"; }); diff --git a/zero/Mails/IMailDispatcher.cs b/Finch/Mails/IMailDispatcher.cs similarity index 95% rename from zero/Mails/IMailDispatcher.cs rename to Finch/Mails/IMailDispatcher.cs index 4f1d95d1..98a888b1 100644 --- a/zero/Mails/IMailDispatcher.cs +++ b/Finch/Mails/IMailDispatcher.cs @@ -1,4 +1,4 @@ -namespace zero.Mails; +namespace Finch.Mails; public interface IMailDispatcher : IDisposable { diff --git a/zero/Mails/LoggerMailDispatcher.cs b/Finch/Mails/LoggerMailDispatcher.cs similarity index 97% rename from zero/Mails/LoggerMailDispatcher.cs rename to Finch/Mails/LoggerMailDispatcher.cs index 9fb4f5e2..bb4c34a5 100644 --- a/zero/Mails/LoggerMailDispatcher.cs +++ b/Finch/Mails/LoggerMailDispatcher.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Logging; -namespace zero.Mails; +namespace Finch.Mails; /// /// Default implementation of an IMailSender which sends the mail to the attached logger diff --git a/zero/Mails/Mail.cs b/Finch/Mails/Mail.cs similarity index 98% rename from zero/Mails/Mail.cs rename to Finch/Mails/Mail.cs index 1255f0d1..595fdc6d 100644 --- a/zero/Mails/Mail.cs +++ b/Finch/Mails/Mail.cs @@ -1,7 +1,7 @@ using System.Net.Mail; using System.Text; -namespace zero.Mails; +namespace Finch.Mails; public class Mail : Mail where T : class { diff --git a/zero/Mails/MailOptions.cs b/Finch/Mails/MailOptions.cs similarity index 95% rename from zero/Mails/MailOptions.cs rename to Finch/Mails/MailOptions.cs index a9c750e9..bd7d7984 100644 --- a/zero/Mails/MailOptions.cs +++ b/Finch/Mails/MailOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Mails; +namespace Finch.Mails; public class MailOptions { diff --git a/zero/Mails/MailProvider.cs b/Finch/Mails/MailProvider.cs similarity index 88% rename from zero/Mails/MailProvider.cs rename to Finch/Mails/MailProvider.cs index 3b2c367f..8c98b451 100644 --- a/zero/Mails/MailProvider.cs +++ b/Finch/Mails/MailProvider.cs @@ -3,13 +3,13 @@ using System.Net.Mail; using System.Reflection; using System.Text; -namespace zero.Mails; +namespace Finch.Mails; public class MailProvider : IMailProvider { protected ILogger Logger { get; set; } - protected IZeroContext Zero { get; set; } + protected IFinchContext Finch { get; set; } protected IMailDispatcher MailSender { get; set; } @@ -20,13 +20,13 @@ public class MailProvider : IMailProvider private Encoding encoding = Encoding.UTF8; - public MailProvider(IZeroContext zero, ILogger logger, IMailDispatcher mailSender, IRazorRenderer renderer) + public MailProvider(IFinchContext finch, ILogger logger, IMailDispatcher mailSender, IRazorRenderer renderer) { - Zero = zero; + Finch = Finch; Logger = logger; MailSender = mailSender; Renderer = renderer; - Options = zero.Options.For(); + Options = Finch.Options.For(); } @@ -77,7 +77,7 @@ public class MailProvider : IMailProvider message.BodyEncoding = encoding; message.Preheader = TokenReplacement.Apply(message.Preheader, message.Placeholders); - string appName = Zero.Options.AppName.Or(Assembly.GetEntryAssembly()?.GetName().Name); + string appName = Finch.Options.AppName.Or(Assembly.GetEntryAssembly()?.GetName().Name); message.Metadata.Add("application", appName); if (!message.HasView || message.Body.HasValue()) diff --git a/zero/Mails/PostmarkDispatcher.cs b/Finch/Mails/PostmarkDispatcher.cs similarity index 99% rename from zero/Mails/PostmarkDispatcher.cs rename to Finch/Mails/PostmarkDispatcher.cs index 3b8c6e82..35d6fd11 100644 --- a/zero/Mails/PostmarkDispatcher.cs +++ b/Finch/Mails/PostmarkDispatcher.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Options; using PostmarkDotNet; using PostmarkDotNet.Model; -namespace zero.Mails; +namespace Finch.Mails; public class PostmarkDispatcher : IMailDispatcher { diff --git a/zero/Mails/PostmarkOptions.cs b/Finch/Mails/PostmarkOptions.cs similarity index 87% rename from zero/Mails/PostmarkOptions.cs rename to Finch/Mails/PostmarkOptions.cs index 3b6e6f1d..43b4312b 100644 --- a/zero/Mails/PostmarkOptions.cs +++ b/Finch/Mails/PostmarkOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Mails; +namespace Finch.Mails; public class PostmarkOptions { diff --git a/zero/Media/ZeroMediaModule.cs b/Finch/Media/FinchMediaModule.cs similarity index 87% rename from zero/Media/ZeroMediaModule.cs rename to Finch/Media/FinchMediaModule.cs index 4e4efd51..55f5a7bd 100644 --- a/zero/Media/ZeroMediaModule.cs +++ b/Finch/Media/FinchMediaModule.cs @@ -7,12 +7,12 @@ using Microsoft.Extensions.Options; using SixLabors.ImageSharp.Web.Caching; using SixLabors.ImageSharp.Web.DependencyInjection; using System.IO; -using zero.Media.ImageSharp; -using zero.Media.ImageSharp.Processors; +using Finch.Media.ImageSharp; +using Finch.Media.ImageSharp.Processors; -namespace zero.Media; +namespace Finch.Media; -internal class ZeroMediaModule : ZeroModule +internal class FinchMediaModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { @@ -29,7 +29,7 @@ internal class ZeroMediaModule : ZeroModule { opts.CacheRootPath = "~/"; opts.CacheFolder = "cache"; - }).Bind(configuration.GetSection("Zero:Media:ImageSharp:Cache")); + }).Bind(configuration.GetSection("Finch:Media:ImageSharp:Cache")); //configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "Config/imaging.json"), true, true); //configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), $"Config/imaging.{builder.Environment.EnvironmentName}.json"), true); @@ -44,7 +44,7 @@ internal class ZeroMediaModule : ZeroModule services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddSingleton(); services.AddSingleton(); @@ -58,9 +58,9 @@ internal class ZeroMediaModule : ZeroModule // { "thumb", new ResizeOptions() { Size = new(100, 100), Mode = ResizeMode.Max } }, // { "preview", new ResizeOptions() { Size = new(210, 210), Mode = ResizeMode.Min } } // }; - }).Bind(configuration.GetSection("Zero:Media")); + }).Bind(configuration.GetSection("Finch:Media")); - // services.Configure(opts => + // services.Configure(opts => // { // RavenOptions raven = opts.For(); // raven.Indexes.Add(); diff --git a/zero/Media/IZeroMediaStoreDbProvider.cs b/Finch/Media/IFinchMediaStoreDbProvider.cs similarity index 62% rename from zero/Media/IZeroMediaStoreDbProvider.cs rename to Finch/Media/IFinchMediaStoreDbProvider.cs index 69fe93b2..22533022 100644 --- a/zero/Media/IZeroMediaStoreDbProvider.cs +++ b/Finch/Media/IFinchMediaStoreDbProvider.cs @@ -1,44 +1,44 @@ using System.Linq.Expressions; -namespace zero.Media; +namespace Finch.Media; -public interface IZeroMediaStoreDbProvider +public interface IFinchMediaStoreDbProvider { - Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> FindAll(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task> FindAll(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new(); } -public class EmptyZeroMediaStoreDbProvider : IZeroMediaStoreDbProvider +public class EmptyFinchMediaStoreDbProvider : IFinchMediaStoreDbProvider { - public Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } - public Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } - public Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity + public Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity { throw new NotImplementedException(); } - public Task> FindAll(Expression> expression, CancellationToken ct = default) where T : ZeroEntity + public Task> FindAll(Expression> expression, CancellationToken ct = default) where T : FinchEntity { throw new NotImplementedException(); } - public Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } diff --git a/zero/Media/ImageDimensionReader.cs b/Finch/Media/ImageDimensionReader.cs similarity index 99% rename from zero/Media/ImageDimensionReader.cs rename to Finch/Media/ImageDimensionReader.cs index 435a2d8f..a51bb5dd 100644 --- a/zero/Media/ImageDimensionReader.cs +++ b/Finch/Media/ImageDimensionReader.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.FileProviders; using SixLabors.ImageSharp; -namespace zero.Media; +namespace Finch.Media; public class ImageDimensionReader : IImageDimensionReader diff --git a/zero/Media/ImageSharp/PhysicalFileProvider.cs b/Finch/Media/ImageSharp/PhysicalFileProvider.cs similarity index 98% rename from zero/Media/ImageSharp/PhysicalFileProvider.cs rename to Finch/Media/ImageSharp/PhysicalFileProvider.cs index 9366ae02..40d41955 100644 --- a/zero/Media/ImageSharp/PhysicalFileProvider.cs +++ b/Finch/Media/ImageSharp/PhysicalFileProvider.cs @@ -6,7 +6,7 @@ using SixLabors.ImageSharp.Web; using SixLabors.ImageSharp.Web.Providers; using SixLabors.ImageSharp.Web.Resolvers; -namespace zero.Media.ImageSharp; +namespace Finch.Media.ImageSharp; /// /// Returns images stored in the local physical file system. diff --git a/zero/Media/ImageSharp/PresetRequestParser.cs b/Finch/Media/ImageSharp/PresetRequestParser.cs similarity index 99% rename from zero/Media/ImageSharp/PresetRequestParser.cs rename to Finch/Media/ImageSharp/PresetRequestParser.cs index 8d3eef68..835d2e52 100644 --- a/zero/Media/ImageSharp/PresetRequestParser.cs +++ b/Finch/Media/ImageSharp/PresetRequestParser.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using SixLabors.ImageSharp.Web.Commands; -namespace zero.Media.ImageSharp; +namespace Finch.Media.ImageSharp; /// /// Parses commands from the request querystring. diff --git a/zero/Media/ImageSharp/Processors/BlurWebProcessor.cs b/Finch/Media/ImageSharp/Processors/BlurWebProcessor.cs similarity index 96% rename from zero/Media/ImageSharp/Processors/BlurWebProcessor.cs rename to Finch/Media/ImageSharp/Processors/BlurWebProcessor.cs index ddb5e49f..4a041757 100644 --- a/zero/Media/ImageSharp/Processors/BlurWebProcessor.cs +++ b/Finch/Media/ImageSharp/Processors/BlurWebProcessor.cs @@ -5,7 +5,7 @@ using SixLabors.ImageSharp.Web.Commands; using SixLabors.ImageSharp.Web.Processors; using System.Globalization; -namespace zero.Media.ImageSharp.Processors; +namespace Finch.Media.ImageSharp.Processors; public class BlurWebProcessor : IImageWebProcessor { diff --git a/zero/Media/ImageSharp/Processors/LoopWebProcessor.cs b/Finch/Media/ImageSharp/Processors/LoopWebProcessor.cs similarity index 97% rename from zero/Media/ImageSharp/Processors/LoopWebProcessor.cs rename to Finch/Media/ImageSharp/Processors/LoopWebProcessor.cs index a08ea0b6..766b53d3 100644 --- a/zero/Media/ImageSharp/Processors/LoopWebProcessor.cs +++ b/Finch/Media/ImageSharp/Processors/LoopWebProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Webp; -namespace zero.Media.ImageSharp.Processors; +namespace Finch.Media.ImageSharp.Processors; public class LoopWebProcessor : IImageWebProcessor { diff --git a/zero/Media/ImageSharp/Processors/RotateWebProcessor.cs b/Finch/Media/ImageSharp/Processors/RotateWebProcessor.cs similarity index 96% rename from zero/Media/ImageSharp/Processors/RotateWebProcessor.cs rename to Finch/Media/ImageSharp/Processors/RotateWebProcessor.cs index 64eb47d4..734c5481 100644 --- a/zero/Media/ImageSharp/Processors/RotateWebProcessor.cs +++ b/Finch/Media/ImageSharp/Processors/RotateWebProcessor.cs @@ -5,7 +5,7 @@ using SixLabors.ImageSharp.Web.Commands; using SixLabors.ImageSharp.Web.Processors; using System.Globalization; -namespace zero.Media.ImageSharp.Processors; +namespace Finch.Media.ImageSharp.Processors; public class RotateWebProcessor : IImageWebProcessor { diff --git a/zero/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs b/Finch/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs similarity index 96% rename from zero/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs rename to Finch/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs index 8b51bb06..945b24e1 100644 --- a/zero/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs +++ b/Finch/Media/ImageSharp/Processors/StripMetadataWebProcessor.cs @@ -5,7 +5,7 @@ using SixLabors.ImageSharp.Web.Processors; using System.Globalization; using SixLabors.ImageSharp.Processing; -namespace zero.Media.ImageSharp.Processors; +namespace Finch.Media.ImageSharp.Processors; public class StripMetadataWebProcessor : IImageWebProcessor { diff --git a/zero/Media/ImageSharp/RemoteImageCache.cs b/Finch/Media/ImageSharp/RemoteImageCache.cs similarity index 98% rename from zero/Media/ImageSharp/RemoteImageCache.cs rename to Finch/Media/ImageSharp/RemoteImageCache.cs index 44087804..9582f5dd 100644 --- a/zero/Media/ImageSharp/RemoteImageCache.cs +++ b/Finch/Media/ImageSharp/RemoteImageCache.cs @@ -1,7 +1,7 @@ // using Microsoft.Extensions.Logging; // using Microsoft.Extensions.Options; // -// namespace zero.Media.ImageSharp; +// namespace Finch.Media.ImageSharp; // // public class RemoteImageCache : IRemoteImageCache // { diff --git a/zero/Media/MediaApplicationBuilderExtensions.cs b/Finch/Media/MediaApplicationBuilderExtensions.cs similarity index 95% rename from zero/Media/MediaApplicationBuilderExtensions.cs rename to Finch/Media/MediaApplicationBuilderExtensions.cs index 4c9c1cb1..83baea95 100644 --- a/zero/Media/MediaApplicationBuilderExtensions.cs +++ b/Finch/Media/MediaApplicationBuilderExtensions.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Net.Http.Headers; -namespace zero.Media; +namespace Finch.Media; public static class MediaApplicationBuilderExtensions { diff --git a/zero/Media/MediaCreator.cs b/Finch/Media/MediaCreator.cs similarity index 97% rename from zero/Media/MediaCreator.cs rename to Finch/Media/MediaCreator.cs index 0f7f3866..5fc171d5 100644 --- a/zero/Media/MediaCreator.cs +++ b/Finch/Media/MediaCreator.cs @@ -10,9 +10,9 @@ using SixLabors.ImageSharp.Processing; using System.IO; using Microsoft.Extensions.Logging; -namespace zero.Media; +namespace Finch.Media; -public class MediaCreator(IMediaFileSystem fileSystem, IZeroOptions options, ILogger logger) : IMediaCreator +public class MediaCreator(IMediaFileSystem fileSystem, IFinchOptions options, ILogger logger) : IMediaCreator { protected IMediaFileSystem FileSystem { get; set; } = fileSystem; diff --git a/zero/Media/MediaExtensions.cs b/Finch/Media/MediaExtensions.cs similarity index 93% rename from zero/Media/MediaExtensions.cs rename to Finch/Media/MediaExtensions.cs index e3a5ab50..cdea6888 100644 --- a/zero/Media/MediaExtensions.cs +++ b/Finch/Media/MediaExtensions.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Web; using System.Numerics; -namespace zero.Media; +namespace Finch.Media; public static class MediaExtensions { @@ -34,9 +34,9 @@ public static class MediaExtensions public static string Resize(this Media media, string preset) => media?.Path.Resize(preset, media?.Metadata?.FocalPoint, true); - public static string Resize(this string path, string preset, bool isZeroMedia) => path.Resize(preset, null, isZeroMedia); + public static string Resize(this string path, string preset, bool isFinchMedia) => path.Resize(preset, null, isFinchMedia); - public static string Resize(this string path, string preset, MediaFocalPoint focalPoint = null, bool isZeroMedia = false) + public static string Resize(this string path, string preset, MediaFocalPoint focalPoint = null, bool isFinchMedia = false) { if (path.IsNullOrEmpty()) { @@ -51,7 +51,7 @@ public static class MediaExtensions return String.Join('/', parts); } - if (isZeroMedia) + if (isFinchMedia) { // TODO this is bullshit because we need to get the base path from options return parts[1] == "media" || parts[0] == "media" diff --git a/zero/Media/MediaFileSystem.cs b/Finch/Media/MediaFileSystem.cs similarity index 96% rename from zero/Media/MediaFileSystem.cs rename to Finch/Media/MediaFileSystem.cs index d90dfdde..398167f3 100644 --- a/zero/Media/MediaFileSystem.cs +++ b/Finch/Media/MediaFileSystem.cs @@ -1,4 +1,4 @@ -namespace zero.Media; +namespace Finch.Media; public class MediaFileSystem : PhysicalFileSystem, IMediaFileSystem { diff --git a/zero/Media/MediaManagement.cs b/Finch/Media/MediaManagement.cs similarity index 96% rename from zero/Media/MediaManagement.cs rename to Finch/Media/MediaManagement.cs index 542ed944..570d8498 100644 --- a/zero/Media/MediaManagement.cs +++ b/Finch/Media/MediaManagement.cs @@ -1,17 +1,17 @@ using System.IO; -namespace zero.Media; +namespace Finch.Media; public class MediaManagement : IMediaManagement { protected IMediaFileSystem FileSystem { get; set; } - protected IZeroMediaStoreDbProvider Db { get; set; } + protected IFinchMediaStoreDbProvider Db { get; set; } protected IMediaCreator Creator { get; set; } - public MediaManagement(IMediaFileSystem fileSystem, IZeroMediaStoreDbProvider db, IMediaCreator creator) + public MediaManagement(IMediaFileSystem fileSystem, IFinchMediaStoreDbProvider db, IMediaCreator creator) { FileSystem = fileSystem; Db = db; diff --git a/zero/Media/MediaManagementExtensions.cs b/Finch/Media/MediaManagementExtensions.cs similarity index 99% rename from zero/Media/MediaManagementExtensions.cs rename to Finch/Media/MediaManagementExtensions.cs index aca499ec..75ae075c 100644 --- a/zero/Media/MediaManagementExtensions.cs +++ b/Finch/Media/MediaManagementExtensions.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Http; using System.IO; -namespace zero.Media +namespace Finch.Media { public static class MediaManagementExtensions { diff --git a/zero/Media/MediaMetadataCache.cs b/Finch/Media/MediaMetadataCache.cs similarity index 90% rename from zero/Media/MediaMetadataCache.cs rename to Finch/Media/MediaMetadataCache.cs index 1407dfc5..c09945f0 100644 --- a/zero/Media/MediaMetadataCache.cs +++ b/Finch/Media/MediaMetadataCache.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Caching.Memory; -namespace zero.Media; +namespace Finch.Media; public sealed class MediaMetadataCache { diff --git a/zero/Media/MediaOptions.cs b/Finch/Media/MediaOptions.cs similarity index 98% rename from zero/Media/MediaOptions.cs rename to Finch/Media/MediaOptions.cs index a8a74905..7a58eca0 100644 --- a/zero/Media/MediaOptions.cs +++ b/Finch/Media/MediaOptions.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Web.Caching; -namespace zero.Media; +namespace Finch.Media; public class MediaOptions { diff --git a/zero/Media/Models/Media.cs b/Finch/Media/Models/Media.cs similarity index 90% rename from zero/Media/Models/Media.cs rename to Finch/Media/Models/Media.cs index 3117244d..65557853 100644 --- a/zero/Media/Models/Media.cs +++ b/Finch/Media/Models/Media.cs @@ -1,9 +1,9 @@ -namespace zero.Media; +namespace Finch.Media; /// /// A media file (can contain an image or other media like videos and documents) /// -public class Media : ZeroEntity, ISupportsTrees +public class Media : FinchEntity, ISupportsTrees { /// /// Whether this media item is a folder or a file @@ -47,7 +47,7 @@ public class Media : ZeroEntity, ISupportsTrees /// /// Define custom thumbnails which are generated on upload - /// (see IZeroOptions.For().Thumbnails) + /// (see IFinchOptions.For().Thumbnails) /// public Dictionary Thumbnails { get; set; } = new(); } \ No newline at end of file diff --git a/zero/Media/Models/MediaFocalPoint.cs b/Finch/Media/Models/MediaFocalPoint.cs similarity index 91% rename from zero/Media/Models/MediaFocalPoint.cs rename to Finch/Media/Models/MediaFocalPoint.cs index 6a89bc3b..c3a7b1f4 100644 --- a/zero/Media/Models/MediaFocalPoint.cs +++ b/Finch/Media/Models/MediaFocalPoint.cs @@ -1,4 +1,4 @@ -namespace zero.Media; +namespace Finch.Media; /// /// The focal point sets the point of interest in an image with x/y coordinates from 0-1 diff --git a/zero/Media/Models/MediaListItem.cs b/Finch/Media/Models/MediaListItem.cs similarity index 85% rename from zero/Media/Models/MediaListItem.cs rename to Finch/Media/Models/MediaListItem.cs index 6d7d92cc..87f8e216 100644 --- a/zero/Media/Models/MediaListItem.cs +++ b/Finch/Media/Models/MediaListItem.cs @@ -1,6 +1,6 @@ -namespace zero.Media; +namespace Finch.Media; -public class MediaListItem : ZeroIdEntity +public class MediaListItem : FinchIdEntity { public string ParentId { get; set; } diff --git a/zero/Media/Models/MediaMetadata.cs b/Finch/Media/Models/MediaMetadata.cs similarity index 95% rename from zero/Media/Models/MediaMetadata.cs rename to Finch/Media/Models/MediaMetadata.cs index 3542a87e..d6991441 100644 --- a/zero/Media/Models/MediaMetadata.cs +++ b/Finch/Media/Models/MediaMetadata.cs @@ -1,4 +1,4 @@ -namespace zero.Media; +namespace Finch.Media; /// /// Metadata for images/videos diff --git a/zero/Media/Models/RemoteMedia.cs b/Finch/Media/Models/RemoteMedia.cs similarity index 81% rename from zero/Media/Models/RemoteMedia.cs rename to Finch/Media/Models/RemoteMedia.cs index 19c11161..295643fe 100644 --- a/zero/Media/Models/RemoteMedia.cs +++ b/Finch/Media/Models/RemoteMedia.cs @@ -1,4 +1,4 @@ -namespace zero.Media; +namespace Finch.Media; public class RemoteMedia : Media { diff --git a/zero/Media/Models/Video.cs b/Finch/Media/Models/Video.cs similarity index 92% rename from zero/Media/Models/Video.cs rename to Finch/Media/Models/Video.cs index 648c2f41..6e757c30 100644 --- a/zero/Media/Models/Video.cs +++ b/Finch/Media/Models/Video.cs @@ -1,4 +1,4 @@ -namespace zero.Media; +namespace Finch.Media; public class Video { diff --git a/zero/Media/StaticMediaCreator.cs b/Finch/Media/StaticMediaCreator.cs similarity index 90% rename from zero/Media/StaticMediaCreator.cs rename to Finch/Media/StaticMediaCreator.cs index bff74aa7..66295b4a 100644 --- a/zero/Media/StaticMediaCreator.cs +++ b/Finch/Media/StaticMediaCreator.cs @@ -5,7 +5,7 @@ using SixLabors.ImageSharp; using System.IO; using Microsoft.Extensions.Logging; -namespace zero.Media; +namespace Finch.Media; public class StaticMediaCreator : MediaCreator, IStaticMediaCreator { @@ -14,7 +14,7 @@ public class StaticMediaCreator : MediaCreator, IStaticMediaCreator protected IFileProvider FileProvider { get; set; } - public StaticMediaCreator(IMediaFileSystem fileSystem, IZeroOptions options, IWebHostEnvironment hostingEnvironment, MediaMetadataCache cacheProvider, ILogger logger) : base(fileSystem, options, logger) + public StaticMediaCreator(IMediaFileSystem fileSystem, IFinchOptions options, IWebHostEnvironment hostingEnvironment, MediaMetadataCache cacheProvider, ILogger logger) : base(fileSystem, options, logger) { FileProvider = hostingEnvironment.WebRootFileProvider; Cache = cacheProvider.Cache; diff --git a/zero/Metadata/Metadata.cs b/Finch/Metadata/Metadata.cs similarity index 93% rename from zero/Metadata/Metadata.cs rename to Finch/Metadata/Metadata.cs index 246e9a57..871ef8cd 100644 --- a/zero/Metadata/Metadata.cs +++ b/Finch/Metadata/Metadata.cs @@ -1,4 +1,4 @@ -namespace zero.Metadata; +namespace Finch.Metadata; public class Metadata { diff --git a/zero/Metadata/MetadataModule.cs b/Finch/Metadata/MetadataModule.cs similarity index 78% rename from zero/Metadata/MetadataModule.cs rename to Finch/Metadata/MetadataModule.cs index 9c6d8484..4d3e7c39 100644 --- a/zero/Metadata/MetadataModule.cs +++ b/Finch/Metadata/MetadataModule.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Metadata; +namespace Finch.Metadata; -public class ZeroMetadataModule : ZeroModule +public class FinchMetadataModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { diff --git a/zero/Metadata/MetadataOptions.cs b/Finch/Metadata/MetadataOptions.cs similarity index 95% rename from zero/Metadata/MetadataOptions.cs rename to Finch/Metadata/MetadataOptions.cs index 029367aa..08aa8519 100644 --- a/zero/Metadata/MetadataOptions.cs +++ b/Finch/Metadata/MetadataOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Metadata; +namespace Finch.Metadata; public class MetadataOptions { diff --git a/zero/Metadata/MetadataService.cs b/Finch/Metadata/MetadataService.cs similarity index 98% rename from zero/Metadata/MetadataService.cs rename to Finch/Metadata/MetadataService.cs index 3b207194..81779013 100644 --- a/zero/Metadata/MetadataService.cs +++ b/Finch/Metadata/MetadataService.cs @@ -2,7 +2,7 @@ using System.Reflection; using System.Text; -namespace zero.Metadata; +namespace Finch.Metadata; public class MetadataService : IMetadataService { diff --git a/zero/Metadata/Schema.cs b/Finch/Metadata/Schema.cs similarity index 97% rename from zero/Metadata/Schema.cs rename to Finch/Metadata/Schema.cs index 2046b170..bddd91da 100644 --- a/zero/Metadata/Schema.cs +++ b/Finch/Metadata/Schema.cs @@ -1,7 +1,7 @@ //using Microsoft.AspNetCore.Mvc; //using System.Dynamic; -//namespace zero.Metadata; +//namespace Finch.Metadata; //public class Schema //{ diff --git a/zero/Models/ZeroEntity.cs b/Finch/Models/FinchEntity.cs similarity index 91% rename from zero/Models/ZeroEntity.cs rename to Finch/Models/FinchEntity.cs index 193ce720..710a0fb7 100644 --- a/zero/Models/ZeroEntity.cs +++ b/Finch/Models/FinchEntity.cs @@ -1,9 +1,9 @@ using System.Diagnostics; -namespace zero.Models; +namespace Finch.Models; [DebuggerDisplay("Id = {Id,nq}, Name = {Name}, Alias = {Alias}")] -public class ZeroEntity : ZeroIdEntity, ISupportsDbConventions, ISupportsRouting, ISupportsFlavors, ISupportsSorting +public class FinchEntity : FinchIdEntity, ISupportsDbConventions, ISupportsRouting, ISupportsFlavors, ISupportsSorting { /// /// Full name of the entity diff --git a/zero/Models/ZeroIdEntity.cs b/Finch/Models/FinchIdEntity.cs similarity index 63% rename from zero/Models/ZeroIdEntity.cs rename to Finch/Models/FinchIdEntity.cs index 8dec8272..caff5fe4 100644 --- a/zero/Models/ZeroIdEntity.cs +++ b/Finch/Models/FinchIdEntity.cs @@ -1,6 +1,6 @@ -namespace zero.Models; +namespace Finch.Models; -public class ZeroIdEntity +public class FinchIdEntity { /// /// Id of the entity diff --git a/Finch/Models/FinchReference.cs b/Finch/Models/FinchReference.cs new file mode 100644 index 00000000..b9569419 --- /dev/null +++ b/Finch/Models/FinchReference.cs @@ -0,0 +1,30 @@ +namespace Finch.Models; + +public class FinchReference +{ + public FinchReference() { } + + public FinchReference(FinchEntity entity) + { + Id = entity.Id; + Name = entity.Name; + } + + public static FinchReference From(FinchEntity entity) + { + return entity == null ? null : new FinchReference(entity); + } + + public static FinchReference From(T entity, Func transform) where T : FinchEntity + { + return entity == null ? null : new FinchReference() + { + Id = entity.Id, + Name = transform(entity) + }; + } + + public string Id { get; set; } + + public string Name { get; set; } +} diff --git a/zero/Models/Flavors/ConfigureFlavorJsonOptions.cs b/Finch/Models/Flavors/ConfigureFlavorJsonOptions.cs similarity index 58% rename from zero/Models/Flavors/ConfigureFlavorJsonOptions.cs rename to Finch/Models/Flavors/ConfigureFlavorJsonOptions.cs index 4f5bdf7b..8480946d 100644 --- a/zero/Models/Flavors/ConfigureFlavorJsonOptions.cs +++ b/Finch/Models/Flavors/ConfigureFlavorJsonOptions.cs @@ -1,20 +1,20 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace zero.Models; +namespace Finch.Models; public class ConfigureFlavorJsonOptions : IConfigureOptions { - private readonly IZeroOptions _zeroOptions; + private readonly IFinchOptions _finchOptions; - public ConfigureFlavorJsonOptions(IZeroOptions options) + public ConfigureFlavorJsonOptions(IFinchOptions options) { - _zeroOptions = options; + _finchOptions = options; } public void Configure(JsonOptions options) { - options.JsonSerializerOptions.Converters.Add(new JsonFlavorVariantConverterFactory(_zeroOptions)); + options.JsonSerializerOptions.Converters.Add(new JsonFlavorVariantConverterFactory(_finchOptions)); } } \ No newline at end of file diff --git a/zero/Models/Flavors/FlavorConfig.cs b/Finch/Models/Flavors/FlavorConfig.cs similarity index 97% rename from zero/Models/Flavors/FlavorConfig.cs rename to Finch/Models/Flavors/FlavorConfig.cs index b104bb66..b7a9bf82 100644 --- a/zero/Models/Flavors/FlavorConfig.cs +++ b/Finch/Models/Flavors/FlavorConfig.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace zero.Models; +namespace Finch.Models; /// /// A flavor config holds information about a flavor implementation diff --git a/zero/Models/Flavors/FlavorOptions.cs b/Finch/Models/Flavors/FlavorOptions.cs similarity index 99% rename from zero/Models/Flavors/FlavorOptions.cs rename to Finch/Models/Flavors/FlavorOptions.cs index aa26b8d2..b6c758c3 100644 --- a/zero/Models/Flavors/FlavorOptions.cs +++ b/Finch/Models/Flavors/FlavorOptions.cs @@ -1,6 +1,6 @@ using System.Collections.Concurrent; -namespace zero.Models; +namespace Finch.Models; public class FlavorOptions { diff --git a/zero/Models/Flavors/FlavorProvider.cs b/Finch/Models/Flavors/FlavorProvider.cs similarity index 96% rename from zero/Models/Flavors/FlavorProvider.cs rename to Finch/Models/Flavors/FlavorProvider.cs index 3bba9463..150f773e 100644 --- a/zero/Models/Flavors/FlavorProvider.cs +++ b/Finch/Models/Flavors/FlavorProvider.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace zero.Models; +namespace Finch.Models; /// /// A flavor provider is attached to an entity (which has ISupportsFlavors) and contains all flavors diff --git a/zero/Models/Flavors/FlavorProviderOptions.cs b/Finch/Models/Flavors/FlavorProviderOptions.cs similarity index 99% rename from zero/Models/Flavors/FlavorProviderOptions.cs rename to Finch/Models/Flavors/FlavorProviderOptions.cs index c4112053..af46e13b 100644 --- a/zero/Models/Flavors/FlavorProviderOptions.cs +++ b/Finch/Models/Flavors/FlavorProviderOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public class FlavorProviderOptions where TEntity : class, ISupportsFlavors, new() { diff --git a/zero/Models/Flavors/JsonFlavorVariantConverter.cs b/Finch/Models/Flavors/JsonFlavorVariantConverter.cs similarity index 97% rename from zero/Models/Flavors/JsonFlavorVariantConverter.cs rename to Finch/Models/Flavors/JsonFlavorVariantConverter.cs index ac4194a8..6defb701 100644 --- a/zero/Models/Flavors/JsonFlavorVariantConverter.cs +++ b/Finch/Models/Flavors/JsonFlavorVariantConverter.cs @@ -1,7 +1,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace zero.Models; +namespace Finch.Models; internal class JsonFlavorVariantConverter : JsonDiscriminatorConverter where T : class, ISupportsFlavors, new() { diff --git a/zero/Models/Flavors/JsonFlavorVariantConverterFactory.cs b/Finch/Models/Flavors/JsonFlavorVariantConverterFactory.cs similarity index 86% rename from zero/Models/Flavors/JsonFlavorVariantConverterFactory.cs rename to Finch/Models/Flavors/JsonFlavorVariantConverterFactory.cs index 2df64a7f..86e06847 100644 --- a/zero/Models/Flavors/JsonFlavorVariantConverterFactory.cs +++ b/Finch/Models/Flavors/JsonFlavorVariantConverterFactory.cs @@ -1,13 +1,13 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace zero.Models; +namespace Finch.Models; public class JsonFlavorVariantConverterFactory : JsonConverterFactory { - readonly IZeroOptions _options; + readonly IFinchOptions _options; - public JsonFlavorVariantConverterFactory(IZeroOptions options) + public JsonFlavorVariantConverterFactory(IFinchOptions options) { _options = options; } diff --git a/zero/Models/ISupportsDbConventions.cs b/Finch/Models/ISupportsDbConventions.cs similarity index 82% rename from zero/Models/ISupportsDbConventions.cs rename to Finch/Models/ISupportsDbConventions.cs index 309576c8..ef0587b7 100644 --- a/zero/Models/ISupportsDbConventions.cs +++ b/Finch/Models/ISupportsDbConventions.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; /// /// Triggers custom conventions for database operations diff --git a/zero/Models/ISupportsFlavors.cs b/Finch/Models/ISupportsFlavors.cs similarity index 88% rename from zero/Models/ISupportsFlavors.cs rename to Finch/Models/ISupportsFlavors.cs index aac608cd..14d7bcb7 100644 --- a/zero/Models/ISupportsFlavors.cs +++ b/Finch/Models/ISupportsFlavors.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public interface ISupportsFlavors { diff --git a/zero/Models/ISupportsRouting.cs b/Finch/Models/ISupportsRouting.cs similarity index 90% rename from zero/Models/ISupportsRouting.cs rename to Finch/Models/ISupportsRouting.cs index 4189bbb3..790441fc 100644 --- a/zero/Models/ISupportsRouting.cs +++ b/Finch/Models/ISupportsRouting.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public interface ISupportsRouting { diff --git a/zero/Models/ISupportsSoftDelete.cs b/Finch/Models/ISupportsSoftDelete.cs similarity index 84% rename from zero/Models/ISupportsSoftDelete.cs rename to Finch/Models/ISupportsSoftDelete.cs index da6f7f29..6859d4d7 100644 --- a/zero/Models/ISupportsSoftDelete.cs +++ b/Finch/Models/ISupportsSoftDelete.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public interface ISupportsSoftDelete { diff --git a/zero/Models/ISupportsSorting.cs b/Finch/Models/ISupportsSorting.cs similarity index 80% rename from zero/Models/ISupportsSorting.cs rename to Finch/Models/ISupportsSorting.cs index 166998cc..c92b1fb4 100644 --- a/zero/Models/ISupportsSorting.cs +++ b/Finch/Models/ISupportsSorting.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public interface ISupportsSorting { diff --git a/zero/Models/ISupportsTrees.cs b/Finch/Models/ISupportsTrees.cs similarity index 91% rename from zero/Models/ISupportsTrees.cs rename to Finch/Models/ISupportsTrees.cs index 437433ac..e4234eca 100644 --- a/zero/Models/ISupportsTrees.cs +++ b/Finch/Models/ISupportsTrees.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public interface ISupportsTrees { diff --git a/zero/Models/Results/Paged.cs b/Finch/Models/Results/Paged.cs similarity index 98% rename from zero/Models/Results/Paged.cs rename to Finch/Models/Results/Paged.cs index d78ed5ad..e9db04fc 100644 --- a/zero/Models/Results/Paged.cs +++ b/Finch/Models/Results/Paged.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public class Paged : Paged { diff --git a/zero/Models/Results/Result.cs b/Finch/Models/Results/Result.cs similarity index 99% rename from zero/Models/Results/Result.cs rename to Finch/Models/Results/Result.cs index 90efb299..8bfd21a5 100644 --- a/zero/Models/Results/Result.cs +++ b/Finch/Models/Results/Result.cs @@ -1,7 +1,7 @@ using FluentValidation.Results; using System.Runtime.Serialization; -namespace zero.Models; +namespace Finch.Models; [DataContract(Name = "result", Namespace = "")] diff --git a/zero/Models/Results/UrlsResult.cs b/Finch/Models/Results/UrlsResult.cs similarity index 97% rename from zero/Models/Results/UrlsResult.cs rename to Finch/Models/Results/UrlsResult.cs index 212c52ec..c4208265 100644 --- a/zero/Models/Results/UrlsResult.cs +++ b/Finch/Models/Results/UrlsResult.cs @@ -1,4 +1,4 @@ -namespace zero.Models; +namespace Finch.Models; public class UrlResult { diff --git a/zero/Modules/ZeroModule.cs b/Finch/Modules/FinchModule.cs similarity index 94% rename from zero/Modules/ZeroModule.cs rename to Finch/Modules/FinchModule.cs index b1303e0f..9d0a5787 100644 --- a/zero/Modules/ZeroModule.cs +++ b/Finch/Modules/FinchModule.cs @@ -3,9 +3,9 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Modules; +namespace Finch.Modules; -public abstract class ZeroModule : IZeroModule +public abstract class FinchModule : IFinchModule { /// public virtual int Order { get; } = 0; @@ -21,7 +21,7 @@ public abstract class ZeroModule : IZeroModule } -public interface IZeroModule +public interface IFinchModule { /// /// Get the value to use to order startups to configure services. The default is 0. diff --git a/zero/Modules/ZeroModuleCollection.cs b/Finch/Modules/FinchModuleCollection.cs similarity index 71% rename from zero/Modules/ZeroModuleCollection.cs rename to Finch/Modules/FinchModuleCollection.cs index 571b15b6..bf0fadf3 100644 --- a/zero/Modules/ZeroModuleCollection.cs +++ b/Finch/Modules/FinchModuleCollection.cs @@ -4,41 +4,41 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System.Collections.Concurrent; -namespace zero.Modules; +namespace Finch.Modules; -public class ZeroModuleCollection : ZeroModule +public class FinchModuleCollection : FinchModule { - ConcurrentDictionary _modules = new(); + ConcurrentDictionary _modules = new(); /// /// Get all registered modules /// - public IEnumerable GetAll() => _modules.Values; + public IEnumerable GetAll() => _modules.Values; /// - /// Adds a zero module + /// Adds a finch module /// - public void Add() where T : class, IZeroModule, new() + public void Add() where T : class, IFinchModule, new() { Add(new T()); } /// - /// Adds a zero module + /// Adds a finch module /// - public void Add(T moduleInstance) where T : IZeroModule + public void Add(T moduleInstance) where T : IFinchModule { Add(typeof(T), moduleInstance); } /// - /// Adds a zero module + /// Adds a finch module /// - public void Add(Type moduleType, IZeroModule moduleInstance) + public void Add(Type moduleType, IFinchModule moduleInstance) { if (_modules.ContainsKey(moduleType)) { diff --git a/zero/Mvc/DisableBrowserCacheFilter.cs b/Finch/Mvc/DisableBrowserCacheFilter.cs similarity index 97% rename from zero/Mvc/DisableBrowserCacheFilter.cs rename to Finch/Mvc/DisableBrowserCacheFilter.cs index 69633552..2ba395d5 100644 --- a/zero/Mvc/DisableBrowserCacheFilter.cs +++ b/Finch/Mvc/DisableBrowserCacheFilter.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Net.Http.Headers; -namespace zero.Mvc; +namespace Finch.Mvc; /// /// Ensures that the request is not cached by the browser diff --git a/Finch/Mvc/FinchApiController.cs b/Finch/Mvc/FinchApiController.cs new file mode 100644 index 00000000..c07a46dd --- /dev/null +++ b/Finch/Mvc/FinchApiController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; + +namespace Finch.Mvc; + +[ApiController] +public abstract class FinchApiController : ControllerBase +{ + IFinchContext _context; + public IFinchContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService()); +} \ No newline at end of file diff --git a/Finch/Mvc/FinchController.cs b/Finch/Mvc/FinchController.cs new file mode 100644 index 00000000..b9637545 --- /dev/null +++ b/Finch/Mvc/FinchController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; + +namespace Finch.Mvc; + +public abstract class FinchController : Controller +{ + IFinchContext _context; + public IFinchContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService()); +} \ No newline at end of file diff --git a/zero/Mvc/ZeroMvcModule.cs b/Finch/Mvc/FinchMvcModule.cs similarity index 85% rename from zero/Mvc/ZeroMvcModule.cs rename to Finch/Mvc/FinchMvcModule.cs index c79da7e4..5b37dc8d 100644 --- a/zero/Mvc/ZeroMvcModule.cs +++ b/Finch/Mvc/FinchMvcModule.cs @@ -4,9 +4,9 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Mvc; +namespace Finch.Mvc; -public class ZeroMvcModule : ZeroModule +public class FinchMvcModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { diff --git a/zero/Mvc/ZeroPageModel.cs b/Finch/Mvc/FinchPageModel.cs similarity index 77% rename from zero/Mvc/ZeroPageModel.cs rename to Finch/Mvc/FinchPageModel.cs index 7949502b..02f98681 100644 --- a/zero/Mvc/ZeroPageModel.cs +++ b/Finch/Mvc/FinchPageModel.cs @@ -2,17 +2,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; -using zero.Metadata; +using Finch.Metadata; -namespace zero.Mvc; +namespace Finch.Mvc; -public abstract class ZeroPageModel : PageModel +public abstract class FinchPageModel : PageModel { /// - /// Get access to the zero context for this request + /// Get access to the finch context for this request /// - public IZeroContext ZeroContext => _zeroContext ??= HttpContext?.RequestServices?.GetService(); - IZeroContext _zeroContext; + public IFinchContext FinchContext => _finchContext ??= HttpContext?.RequestServices?.GetService(); + IFinchContext _finchContext; /// /// Get access to the localizer diff --git a/zero/Numbers/ZeroNumberModule.cs b/Finch/Numbers/FinchNumberModule.cs similarity index 68% rename from zero/Numbers/ZeroNumberModule.cs rename to Finch/Numbers/FinchNumberModule.cs index c79787ad..cc0340fd 100644 --- a/zero/Numbers/ZeroNumberModule.cs +++ b/Finch/Numbers/FinchNumberModule.cs @@ -2,16 +2,16 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Numbers; +namespace Finch.Numbers; -internal class ZeroNumberModule : ZeroModule +internal class FinchNumberModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { - services.AddOptions().Bind(configuration.GetSection("Zero:Numbers")); + services.AddOptions().Bind(configuration.GetSection("Finch:Numbers")); services.AddScoped(); services.AddScoped, NumberValidator>(); - services.AddScoped(); + services.AddScoped(); } } \ No newline at end of file diff --git a/zero/Numbers/IZeroNumberStoreDbProvider.cs b/Finch/Numbers/IFinchNumberStoreDbProvider.cs similarity index 63% rename from zero/Numbers/IZeroNumberStoreDbProvider.cs rename to Finch/Numbers/IFinchNumberStoreDbProvider.cs index 51f4ad35..2354137d 100644 --- a/zero/Numbers/IZeroNumberStoreDbProvider.cs +++ b/Finch/Numbers/IFinchNumberStoreDbProvider.cs @@ -1,52 +1,52 @@ using System.Linq.Expressions; -using zero.Numbers; +using Finch.Numbers; -namespace zero.Numbers; +namespace Finch.Numbers; -public interface IZeroNumberStoreDbProvider +public interface IFinchNumberStoreDbProvider { - Task Load(string id, CancellationToken ct = default) where T : ZeroEntity, new(); + Task Load(string id, CancellationToken ct = default) where T : FinchEntity, new(); - Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> FindAll(Expression> expression, CancellationToken ct = default) where T : ZeroEntity; + Task> FindAll(Expression> expression, CancellationToken ct = default) where T : FinchEntity; - Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new(); - Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new(); + Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new(); } -public class EmptyZeroNumberStoreDbProvider : IZeroNumberStoreDbProvider +public class EmptyFinchNumberStoreDbProvider : IFinchNumberStoreDbProvider { - public Task> Create(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Create(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } - public Task> Delete(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Delete(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } - public Task Find(Expression> expression, CancellationToken ct = default) where T : ZeroEntity + public Task Find(Expression> expression, CancellationToken ct = default) where T : FinchEntity { throw new NotImplementedException(); } - public Task> FindAll(Expression> expression, CancellationToken ct = default) where T : ZeroEntity + public Task> FindAll(Expression> expression, CancellationToken ct = default) where T : FinchEntity { throw new NotImplementedException(); } - public Task Load(string id, CancellationToken ct = default) where T : ZeroEntity, new() + public Task Load(string id, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } - public Task> Update(T model, CancellationToken ct = default) where T : ZeroEntity, new() + public Task> Update(T model, CancellationToken ct = default) where T : FinchEntity, new() { throw new NotImplementedException(); } diff --git a/zero/Numbers/Number.cs b/Finch/Numbers/Number.cs similarity index 96% rename from zero/Numbers/Number.cs rename to Finch/Numbers/Number.cs index a30969e0..9f2223e6 100644 --- a/zero/Numbers/Number.cs +++ b/Finch/Numbers/Number.cs @@ -1,4 +1,4 @@ -namespace zero.Numbers; +namespace Finch.Numbers; /// /// Configuration of number generation @@ -10,7 +10,7 @@ /// {date} for the date in dd-mm-yyyy /// {date:dmy} for the date in a custom format, where dmy is a nested placeholder for the format /// -public class Number : ZeroEntity +public class Number : FinchEntity { /// /// The template to build the number. diff --git a/zero/Numbers/NumberOptions.cs b/Finch/Numbers/NumberOptions.cs similarity index 92% rename from zero/Numbers/NumberOptions.cs rename to Finch/Numbers/NumberOptions.cs index d05eaa76..8e2e6074 100644 --- a/zero/Numbers/NumberOptions.cs +++ b/Finch/Numbers/NumberOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Numbers; +namespace Finch.Numbers; public class NumberOptions : Dictionary { diff --git a/zero/Numbers/NumberValidator.cs b/Finch/Numbers/NumberValidator.cs similarity index 82% rename from zero/Numbers/NumberValidator.cs rename to Finch/Numbers/NumberValidator.cs index 18bed326..8fcbf2e6 100644 --- a/zero/Numbers/NumberValidator.cs +++ b/Finch/Numbers/NumberValidator.cs @@ -1,8 +1,8 @@ using FluentValidation; -namespace zero.Numbers; +namespace Finch.Numbers; -public class NumberValidator : ZeroValidator +public class NumberValidator : FinchValidator { public NumberValidator() { diff --git a/zero/Numbers/Numbers.cs b/Finch/Numbers/Numbers.cs similarity index 96% rename from zero/Numbers/Numbers.cs rename to Finch/Numbers/Numbers.cs index 9e35e537..1153cea0 100644 --- a/zero/Numbers/Numbers.cs +++ b/Finch/Numbers/Numbers.cs @@ -1,12 +1,12 @@ using System.Text.RegularExpressions; -namespace zero.Numbers; +namespace Finch.Numbers; public class Numbers : INumbers { - protected IZeroNumberStoreDbProvider Db { get; set; } + protected IFinchNumberStoreDbProvider Db { get; set; } - protected IZeroOptions Options { get; set; } + protected IFinchOptions Options { get; set; } const string DEFAULT_COUNTER = "Default"; Regex templateRegex = new("{(date|number|year|random):?([a-zA-Z0-9-_]*)}", RegexOptions.IgnoreCase); @@ -14,7 +14,7 @@ public class Numbers : INumbers Random random = new(); - public Numbers(IZeroNumberStoreDbProvider db, IZeroOptions options) + public Numbers(IFinchNumberStoreDbProvider db, IFinchOptions options) { Db = db; Options = options; @@ -189,7 +189,7 @@ public class Numbers : INumbers if (options == null) { - throw new KeyNotFoundException($"Could not find number options (zero:numbers:) for alias {alias}"); + throw new KeyNotFoundException($"Could not find number options (finch:numbers:) for alias {alias}"); } string id = Id(alias); diff --git a/zero/Rendering/ZeroRenderingModule.cs b/Finch/Rendering/FinchRenderingModule.cs similarity index 77% rename from zero/Rendering/ZeroRenderingModule.cs rename to Finch/Rendering/FinchRenderingModule.cs index 261d1df0..4395a4fb 100644 --- a/zero/Rendering/ZeroRenderingModule.cs +++ b/Finch/Rendering/FinchRenderingModule.cs @@ -1,14 +1,14 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Rendering; +namespace Finch.Rendering; -public class ZeroRenderingModule : ZeroModule +public class FinchRenderingModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddScoped(); - services.AddOptions().Bind(configuration.GetSection("Zero:Icons")); + services.AddOptions().Bind(configuration.GetSection("Finch:Icons")); } } \ No newline at end of file diff --git a/zero/Rendering/IconOptions.cs b/Finch/Rendering/IconOptions.cs similarity index 93% rename from zero/Rendering/IconOptions.cs rename to Finch/Rendering/IconOptions.cs index d365853f..8949b5af 100644 --- a/zero/Rendering/IconOptions.cs +++ b/Finch/Rendering/IconOptions.cs @@ -1,4 +1,4 @@ -namespace zero.Rendering; +namespace Finch.Rendering; public class IconOptions : IconSetOptions { diff --git a/zero/Rendering/QrCode/BitArrayExtensions.cs b/Finch/Rendering/QrCode/BitArrayExtensions.cs similarity index 99% rename from zero/Rendering/QrCode/BitArrayExtensions.cs rename to Finch/Rendering/QrCode/BitArrayExtensions.cs index cd2becb8..fd8e8c53 100644 --- a/zero/Rendering/QrCode/BitArrayExtensions.cs +++ b/Finch/Rendering/QrCode/BitArrayExtensions.cs @@ -28,7 +28,7 @@ using System; using System.Collections; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Extension methods for the class. diff --git a/zero/Rendering/QrCode/DataTooLongException.cs b/Finch/Rendering/QrCode/DataTooLongException.cs similarity index 98% rename from zero/Rendering/QrCode/DataTooLongException.cs rename to Finch/Rendering/QrCode/DataTooLongException.cs index ca7f7c22..3bd33dd0 100644 --- a/zero/Rendering/QrCode/DataTooLongException.cs +++ b/Finch/Rendering/QrCode/DataTooLongException.cs @@ -28,7 +28,7 @@ using System; using System.Collections; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// The exception that is thrown when the supplied data does not fit in the QR code. diff --git a/zero/Rendering/QrCode/Objects.cs b/Finch/Rendering/QrCode/Objects.cs similarity index 98% rename from zero/Rendering/QrCode/Objects.cs rename to Finch/Rendering/QrCode/Objects.cs index d61c420e..34427644 100644 --- a/zero/Rendering/QrCode/Objects.cs +++ b/Finch/Rendering/QrCode/Objects.cs @@ -28,7 +28,7 @@ using System; using System.Collections; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Helper functions to check for valid arguments. diff --git a/zero/Rendering/QrCode/QrCode.cs b/Finch/Rendering/QrCode/QrCode.cs similarity index 99% rename from zero/Rendering/QrCode/QrCode.cs rename to Finch/Rendering/QrCode/QrCode.cs index 3c6cbe6d..86d9dc2f 100644 --- a/zero/Rendering/QrCode/QrCode.cs +++ b/Finch/Rendering/QrCode/QrCode.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Represents a QR code containing text or binary data. @@ -813,7 +813,7 @@ public class QrCode // The function modules must be marked and the codeword bits must be drawn // before masking. Due to the arithmetic of XOR, calling applyMask() with // the same mask value a second time will undo the mask. A final well-formed - // QR code needs exactly one (not zero, two, etc.) mask applied. + // QR code needs exactly one (not finch, two, etc.) mask applied. private void ApplyMask(uint mask) { if (mask > 7) diff --git a/zero/Rendering/QrCode/QrSegment.cs b/Finch/Rendering/QrCode/QrSegment.cs similarity index 99% rename from zero/Rendering/QrCode/QrSegment.cs rename to Finch/Rendering/QrCode/QrSegment.cs index a7a46c5b..e1a54e96 100644 --- a/zero/Rendering/QrCode/QrSegment.cs +++ b/Finch/Rendering/QrCode/QrSegment.cs @@ -31,7 +31,7 @@ using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Represents a segment of character/binary/control data in a QR code symbol. @@ -153,7 +153,7 @@ public class QrSegment /// - /// Creates a list of zero or more segments representing the specified text string. + /// Creates a list of finch or more segments representing the specified text string. /// /// The text may contain the full range of Unicode characters. /// diff --git a/zero/Rendering/QrCode/QrSegmentAdvanced.cs b/Finch/Rendering/QrCode/QrSegmentAdvanced.cs similarity index 99% rename from zero/Rendering/QrCode/QrSegmentAdvanced.cs rename to Finch/Rendering/QrCode/QrSegmentAdvanced.cs index bffd9a9d..24f35bf7 100644 --- a/zero/Rendering/QrCode/QrSegmentAdvanced.cs +++ b/Finch/Rendering/QrCode/QrSegmentAdvanced.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; -using static zero.Rendering.QrCode.QrSegment; +using static Finch.Rendering.QrCode.QrSegment; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Advanced methods for encoding QR codes using Kanji mode or using multiple segments with different encodings. @@ -45,7 +45,7 @@ public static class QrSegmentAdvanced #region Optimal list of segments encoder /// - /// Creates a list of zero or more segments to represent the specified text string. + /// Creates a list of finch or more segments to represent the specified text string. /// The resulting list optimally minimizes the total encoded bit length, subjected to the constraints /// of the specified error correction level, minimum and maximum version number. /// diff --git a/zero/Rendering/QrCode/ReedSolomonGenerator.cs b/Finch/Rendering/QrCode/ReedSolomonGenerator.cs similarity index 99% rename from zero/Rendering/QrCode/ReedSolomonGenerator.cs rename to Finch/Rendering/QrCode/ReedSolomonGenerator.cs index a4b1034e..251b4965 100644 --- a/zero/Rendering/QrCode/ReedSolomonGenerator.cs +++ b/Finch/Rendering/QrCode/ReedSolomonGenerator.cs @@ -29,7 +29,7 @@ using System; using System.Collections; using System.Diagnostics; -namespace zero.Rendering.QrCode; +namespace Finch.Rendering.QrCode; /// /// Computes the Reed-Solomon error correction codewords for a sequence of data codewords at a given degree. diff --git a/zero/Rendering/RazorRenderer.cs b/Finch/Rendering/RazorRenderer.cs similarity index 99% rename from zero/Rendering/RazorRenderer.cs rename to Finch/Rendering/RazorRenderer.cs index 96ba2fab..0ed120b1 100644 --- a/zero/Rendering/RazorRenderer.cs +++ b/Finch/Rendering/RazorRenderer.cs @@ -15,7 +15,7 @@ using System.Diagnostics; using System.IO; using System.Text.Encodings.Web; -namespace zero.Rendering; +namespace Finch.Rendering; public class RazorRenderer : IRazorRenderer, IDisposable { diff --git a/zero/Resources/cap_min_0_1_41.js b/Finch/Resources/cap_min_0_1_41.js similarity index 100% rename from zero/Resources/cap_min_0_1_41.js rename to Finch/Resources/cap_min_0_1_41.js diff --git a/zero/Resources/cap_wasm_bg_0_0_6.wasm b/Finch/Resources/cap_wasm_bg_0_0_6.wasm similarity index 100% rename from zero/Resources/cap_wasm_bg_0_0_6.wasm rename to Finch/Resources/cap_wasm_bg_0_0_6.wasm diff --git a/zero/Routing/ZeroRoutingModule.cs b/Finch/Routing/FinchRoutingModule.cs similarity index 78% rename from zero/Routing/ZeroRoutingModule.cs rename to Finch/Routing/FinchRoutingModule.cs index 8ff86cbb..06211fc7 100644 --- a/zero/Routing/ZeroRoutingModule.cs +++ b/Finch/Routing/FinchRoutingModule.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Routing; +namespace Finch.Routing; -internal class ZeroRoutingModule : ZeroModule +internal class FinchRoutingModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { diff --git a/zero/Routing/RequestUrlResolver.cs b/Finch/Routing/RequestUrlResolver.cs similarity index 99% rename from zero/Routing/RequestUrlResolver.cs rename to Finch/Routing/RequestUrlResolver.cs index 0e605b5b..e6ccf83a 100644 --- a/zero/Routing/RequestUrlResolver.cs +++ b/Finch/Routing/RequestUrlResolver.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; -namespace zero.Routing; +namespace Finch.Routing; public class RequestUrlResolver : IRequestUrlResolver { diff --git a/zero/Security/CaptchaController.cs b/Finch/Security/CaptchaController.cs similarity index 81% rename from zero/Security/CaptchaController.cs rename to Finch/Security/CaptchaController.cs index 8b96f384..e891023a 100644 --- a/zero/Security/CaptchaController.cs +++ b/Finch/Security/CaptchaController.cs @@ -3,13 +3,13 @@ using System.Reflection; using Microsoft.AspNetCore.Mvc; using PowCapServer.Abstractions; using PowCapServer.Models; -using zero.Mvc; +using Finch.Mvc; -namespace zero.Security; +namespace Finch.Security; [ApiController] [Route("/api/captcha")] -public class CaptchaController(ICaptchaService captchaService) : ZeroController +public class CaptchaController(ICaptchaService captchaService) : FinchController { [HttpPost("challenge")] public async Task PostChallenge() @@ -56,8 +56,8 @@ public class CaptchaController(ICaptchaService captchaService) : ZeroController [HttpGet("cap.wasm")] public IActionResult GetWasmFile() { - Assembly assembly = typeof(ZeroSecurityModule).GetTypeInfo().Assembly; - Stream resource = assembly.GetManifestResourceStream("zero.Resources.cap_wasm_bg_0_0_6.wasm"); + Assembly assembly = typeof(FinchSecurityModule).GetTypeInfo().Assembly; + Stream resource = assembly.GetManifestResourceStream("Finch.Resources.cap_wasm_bg_0_0_6.wasm"); if (resource is null) { @@ -71,8 +71,8 @@ public class CaptchaController(ICaptchaService captchaService) : ZeroController [HttpGet("cap.widget.js")] public IActionResult GetWidgetJsFile() { - Assembly assembly = typeof(ZeroSecurityModule).GetTypeInfo().Assembly; - Stream resource = assembly.GetManifestResourceStream("zero.Resources.cap_min_0_1_41.js"); + Assembly assembly = typeof(FinchSecurityModule).GetTypeInfo().Assembly; + Stream resource = assembly.GetManifestResourceStream("Finch.Resources.cap_min_0_1_41.js"); if (resource is null) { diff --git a/zero/Security/CaptchaOptions.cs b/Finch/Security/CaptchaOptions.cs similarity index 98% rename from zero/Security/CaptchaOptions.cs rename to Finch/Security/CaptchaOptions.cs index 0abd369b..4159171d 100644 --- a/zero/Security/CaptchaOptions.cs +++ b/Finch/Security/CaptchaOptions.cs @@ -1,6 +1,6 @@ using PowCapServer; -namespace zero.Security; +namespace Finch.Security; public class CaptchaOptions : PowCapConfig { diff --git a/zero/Security/CaptchaTagHelper.cs b/Finch/Security/CaptchaTagHelper.cs similarity index 97% rename from zero/Security/CaptchaTagHelper.cs rename to Finch/Security/CaptchaTagHelper.cs index 195a82c3..bcf345a1 100644 --- a/zero/Security/CaptchaTagHelper.cs +++ b/Finch/Security/CaptchaTagHelper.cs @@ -2,9 +2,9 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; -using zero.Security; +using Finch.Security; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement("app-captcha", TagStructure = TagStructure.NormalOrSelfClosing)] public class CaptchaTagHelper(IOptionsMonitor options) : TagHelper diff --git a/zero/Security/CaptchaValidator.cs b/Finch/Security/CaptchaValidator.cs similarity index 92% rename from zero/Security/CaptchaValidator.cs rename to Finch/Security/CaptchaValidator.cs index c3dc1c03..920c6df2 100644 --- a/zero/Security/CaptchaValidator.cs +++ b/Finch/Security/CaptchaValidator.cs @@ -1,9 +1,9 @@ using FluentValidation; using FluentValidation.Validators; using PowCapServer.Abstractions; -using zero.Validation.Validators; +using Finch.Validation.Validators; -namespace zero.Security; +namespace Finch.Security; public sealed class CaptchaValidator : AsyncPropertyValidator { diff --git a/zero/Security/ZeroSecurityModule.cs b/Finch/Security/FinchSecurityModule.cs similarity index 92% rename from zero/Security/ZeroSecurityModule.cs rename to Finch/Security/FinchSecurityModule.cs index 0ff9968b..23842000 100644 --- a/zero/Security/ZeroSecurityModule.cs +++ b/Finch/Security/FinchSecurityModule.cs @@ -6,13 +6,13 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using PowCapServer; using PowCapServer.Abstractions; -namespace zero.Security; +namespace Finch.Security; -internal class ZeroSecurityModule : ZeroModule +internal class FinchSecurityModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { - IConfigurationSection captchaSection = configuration.GetSection("Zero:Captcha"); + IConfigurationSection captchaSection = configuration.GetSection("Finch:Captcha"); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/zero/Security/NameAndIdProviderCopy.cs b/Finch/Security/NameAndIdProviderCopy.cs similarity index 99% rename from zero/Security/NameAndIdProviderCopy.cs rename to Finch/Security/NameAndIdProviderCopy.cs index b0c35ad8..27ec9426 100644 --- a/zero/Security/NameAndIdProviderCopy.cs +++ b/Finch/Security/NameAndIdProviderCopy.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; -namespace zero.Security; +namespace Finch.Security; /// /// Provides cached values for "name" and "id" HTML attributes. diff --git a/zero/Security/StaticCaptchaService.cs b/Finch/Security/StaticCaptchaService.cs similarity index 93% rename from zero/Security/StaticCaptchaService.cs rename to Finch/Security/StaticCaptchaService.cs index 1b791db6..2fab67be 100644 --- a/zero/Security/StaticCaptchaService.cs +++ b/Finch/Security/StaticCaptchaService.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using PowCapServer.Abstractions; -namespace zero.Security; +namespace Finch.Security; internal static class StaticCaptchaService { diff --git a/zero/Security/ValidatorExtensions.cs b/Finch/Security/ValidatorExtensions.cs similarity index 86% rename from zero/Security/ValidatorExtensions.cs rename to Finch/Security/ValidatorExtensions.cs index 006428fd..79655722 100644 --- a/zero/Security/ValidatorExtensions.cs +++ b/Finch/Security/ValidatorExtensions.cs @@ -1,7 +1,7 @@ using FluentValidation; -using zero.Security; +using Finch.Security; -namespace zero.Validation; +namespace Finch.Validation; public static partial class ValidatorExtensions { diff --git a/Finch/ServiceCollectionExtensions.cs b/Finch/ServiceCollectionExtensions.cs new file mode 100644 index 00000000..3f42d4e3 --- /dev/null +++ b/Finch/ServiceCollectionExtensions.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace Finch; + +public static class ServiceCollectionExtensions +{ + public static FinchBuilder AddFinch(this IServiceCollection services, IConfiguration configuration) + { + return new FinchBuilder(services, configuration, null); + } + + public static FinchBuilder AddFinch(this IServiceCollection services, IConfiguration configuration, Action setupAction) + { + return new FinchBuilder(services, configuration, setupAction); + } +} \ No newline at end of file diff --git a/zero/TagHelpers/ActiveTagHelper.cs b/Finch/TagHelpers/ActiveTagHelper.cs similarity index 97% rename from zero/TagHelpers/ActiveTagHelper.cs rename to Finch/TagHelpers/ActiveTagHelper.cs index 8d663399..166e8196 100644 --- a/zero/TagHelpers/ActiveTagHelper.cs +++ b/Finch/TagHelpers/ActiveTagHelper.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement(Attributes = "app-active")] public class ActiveTagHelper(IHttpContextAccessor contextAccessor) : TagHelper diff --git a/zero/TagHelpers/ClassTagHelper.cs b/Finch/TagHelpers/ClassTagHelper.cs similarity index 96% rename from zero/TagHelpers/ClassTagHelper.cs rename to Finch/TagHelpers/ClassTagHelper.cs index c4b1c74f..1bc392ca 100644 --- a/zero/TagHelpers/ClassTagHelper.cs +++ b/Finch/TagHelpers/ClassTagHelper.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement(Attributes = Prefix + "*")] public class ClassTagHelper : TagHelper diff --git a/zero/TagHelpers/IconTagHelper.cs b/Finch/TagHelpers/IconTagHelper.cs similarity index 99% rename from zero/TagHelpers/IconTagHelper.cs rename to Finch/TagHelpers/IconTagHelper.cs index 3a0531b3..32eeb809 100644 --- a/zero/TagHelpers/IconTagHelper.cs +++ b/Finch/TagHelpers/IconTagHelper.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement("app-icon", TagStructure = TagStructure.NormalOrSelfClosing)] public class IconTagHelper : TagHelper diff --git a/zero/TagHelpers/IfTagHelper.cs b/Finch/TagHelpers/IfTagHelper.cs similarity index 91% rename from zero/TagHelpers/IfTagHelper.cs rename to Finch/TagHelpers/IfTagHelper.cs index 37c260fc..3907c808 100644 --- a/zero/TagHelpers/IfTagHelper.cs +++ b/Finch/TagHelpers/IfTagHelper.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement(Attributes = "app-if")] public class IfTagHelper : TagHelper diff --git a/zero/TagHelpers/MultilineTagHelper.cs b/Finch/TagHelpers/MultilineTagHelper.cs similarity index 93% rename from zero/TagHelpers/MultilineTagHelper.cs rename to Finch/TagHelpers/MultilineTagHelper.cs index 2c842f70..3275d967 100644 --- a/zero/TagHelpers/MultilineTagHelper.cs +++ b/Finch/TagHelpers/MultilineTagHelper.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement("app-multiline", Attributes = "text")] public class MultilineTagHelper : TagHelper diff --git a/zero/TagHelpers/ResizeTagHelper.cs b/Finch/TagHelpers/ResizeTagHelper.cs similarity index 98% rename from zero/TagHelpers/ResizeTagHelper.cs rename to Finch/TagHelpers/ResizeTagHelper.cs index 88f23070..8b480b84 100644 --- a/zero/TagHelpers/ResizeTagHelper.cs +++ b/Finch/TagHelpers/ResizeTagHelper.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement(Attributes = "app-resize")] public class ResizeTagHelper : TagHelper diff --git a/zero/TagHelpers/StripHtmlTagHelper.cs b/Finch/TagHelpers/StripHtmlTagHelper.cs similarity index 96% rename from zero/TagHelpers/StripHtmlTagHelper.cs rename to Finch/TagHelpers/StripHtmlTagHelper.cs index 2ab2c743..f79ca471 100644 --- a/zero/TagHelpers/StripHtmlTagHelper.cs +++ b/Finch/TagHelpers/StripHtmlTagHelper.cs @@ -2,7 +2,7 @@ using System.Net; using static System.Text.RegularExpressions.Regex; -namespace zero.TagHelpers; +namespace Finch.TagHelpers; [HtmlTargetElement("app-striphtml", Attributes = "text")] public class StripHtmlTagHelper : TagHelper diff --git a/Finch/Usings.cs b/Finch/Usings.cs new file mode 100644 index 00000000..cf0aa4ad --- /dev/null +++ b/Finch/Usings.cs @@ -0,0 +1,22 @@ + +global using System; +global using System.Collections; +global using System.Collections.Generic; +global using System.Linq; +global using System.Threading; +global using System.Threading.Tasks; + +//global using Finch.Persistence; +global using Finch.Utils; +global using Finch.Configuration; +global using Finch.Extensions; +global using Finch.FileStorage; +global using Finch.Models; +global using Finch.Modules; +global using Finch.Media; +global using Finch.Rendering; +global using Finch.Validation; +global using Finch.Localization; +global using Finch.Context; +global using Finch.Communication; +global using Finch.Assemblies; diff --git a/zero/Utils/Base32.cs b/Finch/Utils/Base32.cs similarity index 99% rename from zero/Utils/Base32.cs rename to Finch/Utils/Base32.cs index 5b030cf7..0d7edb62 100644 --- a/zero/Utils/Base32.cs +++ b/Finch/Utils/Base32.cs @@ -1,6 +1,6 @@ using System.Text; -namespace zero.Utils; +namespace Finch.Utils; // This is a re-implementation of ASP.NET Core Base32, as they have marked it as internal // by using this we can create user security stamps on the fly and don't need diff --git a/zero/Utils/DateRange.cs b/Finch/Utils/DateRange.cs similarity index 96% rename from zero/Utils/DateRange.cs rename to Finch/Utils/DateRange.cs index 3650671f..f5cec28e 100644 --- a/zero/Utils/DateRange.cs +++ b/Finch/Utils/DateRange.cs @@ -1,4 +1,4 @@ -namespace zero.Utils; +namespace Finch.Utils; public class DateRange { diff --git a/zero/Utils/GenerateIdAttribute.cs b/Finch/Utils/GenerateIdAttribute.cs similarity index 93% rename from zero/Utils/GenerateIdAttribute.cs rename to Finch/Utils/GenerateIdAttribute.cs index 5659f801..c14ccd52 100644 --- a/zero/Utils/GenerateIdAttribute.cs +++ b/Finch/Utils/GenerateIdAttribute.cs @@ -1,4 +1,4 @@ -namespace zero.Utils; +namespace Finch.Utils; /// /// Automatically generate ID with the specified length and insert it into this property on entity save diff --git a/zero/Utils/IdGenerator.cs b/Finch/Utils/IdGenerator.cs similarity index 99% rename from zero/Utils/IdGenerator.cs rename to Finch/Utils/IdGenerator.cs index 86155bd2..8c9ff14b 100644 --- a/zero/Utils/IdGenerator.cs +++ b/Finch/Utils/IdGenerator.cs @@ -1,6 +1,6 @@ using System.Text.Json; -namespace zero.Utils; +namespace Finch.Utils; public class IdGenerator { diff --git a/zero/Utils/JsonDiscriminatorConverter.cs b/Finch/Utils/JsonDiscriminatorConverter.cs similarity index 98% rename from zero/Utils/JsonDiscriminatorConverter.cs rename to Finch/Utils/JsonDiscriminatorConverter.cs index d0471338..c0c2e7a2 100644 --- a/zero/Utils/JsonDiscriminatorConverter.cs +++ b/Finch/Utils/JsonDiscriminatorConverter.cs @@ -1,7 +1,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace zero.Utils; +namespace Finch.Utils; public abstract class JsonDiscriminatorConverter : JsonConverter where T : class, new() { diff --git a/zero/Utils/ObjectCopycat.cs b/Finch/Utils/ObjectCopycat.cs similarity index 99% rename from zero/Utils/ObjectCopycat.cs rename to Finch/Utils/ObjectCopycat.cs index 5e5678f2..51927f98 100644 --- a/zero/Utils/ObjectCopycat.cs +++ b/Finch/Utils/ObjectCopycat.cs @@ -2,7 +2,7 @@ using System.Reflection; using System.Text.Json; -namespace zero.Utils; +namespace Finch.Utils; public class ObjectCopycat { diff --git a/zero/Utils/ObjectTraverser.cs b/Finch/Utils/ObjectTraverser.cs similarity index 99% rename from zero/Utils/ObjectTraverser.cs rename to Finch/Utils/ObjectTraverser.cs index f5de7b9c..4ac874ec 100644 --- a/zero/Utils/ObjectTraverser.cs +++ b/Finch/Utils/ObjectTraverser.cs @@ -1,6 +1,6 @@ using System.Reflection; -namespace zero.Utils; +namespace Finch.Utils; public class ObjectTraverser { diff --git a/zero/Utils/PasswordGenerator.cs b/Finch/Utils/PasswordGenerator.cs similarity index 94% rename from zero/Utils/PasswordGenerator.cs rename to Finch/Utils/PasswordGenerator.cs index 531f6bb5..ccc09ecd 100644 --- a/zero/Utils/PasswordGenerator.cs +++ b/Finch/Utils/PasswordGenerator.cs @@ -1,4 +1,4 @@ -namespace zero.Utils; +namespace Finch.Utils; public class PasswordGenerator { diff --git a/zero/Utils/PriceRange.cs b/Finch/Utils/PriceRange.cs similarity index 79% rename from zero/Utils/PriceRange.cs rename to Finch/Utils/PriceRange.cs index 1d764d94..74176187 100644 --- a/zero/Utils/PriceRange.cs +++ b/Finch/Utils/PriceRange.cs @@ -1,4 +1,4 @@ -namespace zero.Utils; +namespace Finch.Utils; public class PriceRange { diff --git a/zero/Utils/PrimitiveTypeCollection.cs b/Finch/Utils/PrimitiveTypeCollection.cs similarity index 98% rename from zero/Utils/PrimitiveTypeCollection.cs rename to Finch/Utils/PrimitiveTypeCollection.cs index 05ae8f4b..46438745 100644 --- a/zero/Utils/PrimitiveTypeCollection.cs +++ b/Finch/Utils/PrimitiveTypeCollection.cs @@ -1,6 +1,6 @@ using System.Collections.Concurrent; -namespace zero.Utils; +namespace Finch.Utils; public class PrimitiveTypeCollection : ConcurrentDictionary, IPrimitiveTypeCollection { diff --git a/zero/Utils/Safenames.cs b/Finch/Utils/Safenames.cs similarity index 99% rename from zero/Utils/Safenames.cs rename to Finch/Utils/Safenames.cs index bcef4901..209e2f9e 100644 --- a/zero/Utils/Safenames.cs +++ b/Finch/Utils/Safenames.cs @@ -1,7 +1,7 @@ using System.IO; using System.Text; -namespace zero.Utils; +namespace Finch.Utils; public class Safenames { diff --git a/zero/Utils/TokenReplacement.cs b/Finch/Utils/TokenReplacement.cs similarity index 97% rename from zero/Utils/TokenReplacement.cs rename to Finch/Utils/TokenReplacement.cs index 1b3a7e3f..9d272f76 100644 --- a/zero/Utils/TokenReplacement.cs +++ b/Finch/Utils/TokenReplacement.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; -namespace zero.Utils; +namespace Finch.Utils; public class TokenReplacement { diff --git a/zero/Validation/ZeroMergedValidator.cs b/Finch/Validation/FinchMergedValidator.cs similarity index 78% rename from zero/Validation/ZeroMergedValidator.cs rename to Finch/Validation/FinchMergedValidator.cs index a33e5fe0..f1addb57 100644 --- a/zero/Validation/ZeroMergedValidator.cs +++ b/Finch/Validation/FinchMergedValidator.cs @@ -2,16 +2,16 @@ using FluentValidation.Results; using System.Collections.Concurrent; -namespace zero.Validation; +namespace Finch.Validation; -public class ZeroMergedValidator : IZeroMergedValidator +public class FinchMergedValidator : IFinchMergedValidator { protected IEnumerable> Validators { get; private set; } ConcurrentDictionary>> TypeCache = new(); - public ZeroMergedValidator(IEnumerable> validators) + public FinchMergedValidator(IEnumerable> validators) { Validators = validators; } @@ -53,7 +53,7 @@ public class ZeroMergedValidator : IZeroMergedValidator bool CanHandle(IValidator validator, Type modelType) { Type validatorType = validator.GetType(); - Type typeToFind = typeof(ZeroValidator<,>); + Type typeToFind = typeof(FinchValidator<,>); Type findValidatorBase(Type type) { @@ -70,21 +70,21 @@ public class ZeroMergedValidator : IZeroMergedValidator return findValidatorBase(type.BaseType); } - Type zeroValidatorType = findValidatorBase(validatorType); + Type finchValidatorType = findValidatorBase(validatorType); - if (zeroValidatorType == null) + if (finchValidatorType == null) { return false; } - Type implementationType = zeroValidatorType.GenericTypeArguments[1]; + Type implementationType = finchValidatorType.GenericTypeArguments[1]; return implementationType.IsAssignableFrom(modelType); } } -public interface IZeroMergedValidator +public interface IFinchMergedValidator { /// /// Get all validators which can run for the given model @@ -92,7 +92,7 @@ public interface IZeroMergedValidator IEnumerable> ResolveFor(T model); /// - /// Validates a model by using all registered ZeroValidators for this entity type + /// Validates a model by using all registered FinchValidators for this entity type /// Task ValidateAsync(T model); } \ No newline at end of file diff --git a/zero/Validation/ZeroValidationModule.cs b/Finch/Validation/FinchValidationModule.cs similarity index 60% rename from zero/Validation/ZeroValidationModule.cs rename to Finch/Validation/FinchValidationModule.cs index 70e43525..56934986 100644 --- a/zero/Validation/ZeroValidationModule.cs +++ b/Finch/Validation/FinchValidationModule.cs @@ -1,13 +1,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace zero.Validation; +namespace Finch.Validation; -internal class ZeroValidationModule : ZeroModule +internal class FinchValidationModule : FinchModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddValidationLanguageExtensions(); - services.AddScoped(typeof(IZeroMergedValidator<>), typeof(ZeroMergedValidator<>)); + services.AddScoped(typeof(IFinchMergedValidator<>), typeof(FinchMergedValidator<>)); } } \ No newline at end of file diff --git a/zero/Validation/ZeroValidator.cs b/Finch/Validation/FinchValidator.cs similarity index 72% rename from zero/Validation/ZeroValidator.cs rename to Finch/Validation/FinchValidator.cs index acdcf9e3..61a59e37 100644 --- a/zero/Validation/ZeroValidator.cs +++ b/Finch/Validation/FinchValidator.cs @@ -1,13 +1,13 @@ using FluentValidation; using FluentValidation.Results; -namespace zero.Validation; +namespace Finch.Validation; -public class ZeroValidator : ZeroValidator +public class FinchValidator : FinchValidator { } -public abstract class ZeroValidator : AbstractValidator, IValidator where TImplementation : TInterface +public abstract class FinchValidator : AbstractValidator, IValidator where TImplementation : TInterface { public ValidationResult Validate(TInterface instance) { diff --git a/zero/Validation/German/FluentValidationEnglishLanguage.cs b/Finch/Validation/German/FluentValidationEnglishLanguage.cs similarity index 91% rename from zero/Validation/German/FluentValidationEnglishLanguage.cs rename to Finch/Validation/German/FluentValidationEnglishLanguage.cs index 290e906c..eb741c3d 100644 --- a/zero/Validation/German/FluentValidationEnglishLanguage.cs +++ b/Finch/Validation/German/FluentValidationEnglishLanguage.cs @@ -1,4 +1,4 @@ -namespace zero.Validation; +namespace Finch.Validation; public class FluentValidationEnglishLanguage { diff --git a/zero/Validation/German/FluentValidationGermanLanguage.cs b/Finch/Validation/German/FluentValidationGermanLanguage.cs similarity index 98% rename from zero/Validation/German/FluentValidationGermanLanguage.cs rename to Finch/Validation/German/FluentValidationGermanLanguage.cs index d981f933..5e622849 100644 --- a/zero/Validation/German/FluentValidationGermanLanguage.cs +++ b/Finch/Validation/German/FluentValidationGermanLanguage.cs @@ -1,4 +1,4 @@ -namespace zero.Validation; +namespace Finch.Validation; public class FluentValidationGermanLanguage { diff --git a/zero/Validation/German/GermanIdentityErrorDescriber.cs b/Finch/Validation/German/GermanIdentityErrorDescriber.cs similarity index 99% rename from zero/Validation/German/GermanIdentityErrorDescriber.cs rename to Finch/Validation/German/GermanIdentityErrorDescriber.cs index 1cf6a8da..c121c09e 100644 --- a/zero/Validation/German/GermanIdentityErrorDescriber.cs +++ b/Finch/Validation/German/GermanIdentityErrorDescriber.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Identity; -namespace zero.Validation; +namespace Finch.Validation; public class GermanIdentityErrorDescriber : IdentityErrorDescriber { diff --git a/zero/Validation/German/ServiceCollectionExtensions.cs b/Finch/Validation/German/ServiceCollectionExtensions.cs similarity index 97% rename from zero/Validation/German/ServiceCollectionExtensions.cs rename to Finch/Validation/German/ServiceCollectionExtensions.cs index 10707b12..c12b7dee 100644 --- a/zero/Validation/German/ServiceCollectionExtensions.cs +++ b/Finch/Validation/German/ServiceCollectionExtensions.cs @@ -3,7 +3,7 @@ using FluentValidation.Resources; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; -namespace zero.Validation; +namespace Finch.Validation; public static class ServiceCollectionExtensions { diff --git a/zero/Validation/ModelStateDictionaryExtensions.cs b/Finch/Validation/ModelStateDictionaryExtensions.cs similarity index 99% rename from zero/Validation/ModelStateDictionaryExtensions.cs rename to Finch/Validation/ModelStateDictionaryExtensions.cs index 19296ec7..67b7201f 100644 --- a/zero/Validation/ModelStateDictionaryExtensions.cs +++ b/Finch/Validation/ModelStateDictionaryExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc.ModelBinding; -namespace zero.Validation; +namespace Finch.Validation; public static class ModelStateDictionaryExtensions { diff --git a/zero/Validation/ValidatorCamelCasePropertyResolver.cs b/Finch/Validation/ValidatorCamelCasePropertyResolver.cs similarity index 96% rename from zero/Validation/ValidatorCamelCasePropertyResolver.cs rename to Finch/Validation/ValidatorCamelCasePropertyResolver.cs index 52c87e72..ddf87f90 100644 --- a/zero/Validation/ValidatorCamelCasePropertyResolver.cs +++ b/Finch/Validation/ValidatorCamelCasePropertyResolver.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using System.Reflection; -namespace zero.Validation; +namespace Finch.Validation; public class ValidatorCamelCasePropertyResolver { diff --git a/zero/Validation/ValidatorExtensions.cs b/Finch/Validation/ValidatorExtensions.cs similarity index 95% rename from zero/Validation/ValidatorExtensions.cs rename to Finch/Validation/ValidatorExtensions.cs index e85c3e40..6bf0a738 100644 --- a/zero/Validation/ValidatorExtensions.cs +++ b/Finch/Validation/ValidatorExtensions.cs @@ -1,7 +1,7 @@ using FluentValidation; -using zero.Validation.Validators; +using Finch.Validation.Validators; -namespace zero.Validation; +namespace Finch.Validation; public static partial class ValidatorExtensions { diff --git a/zero/Validation/Validators/CultureValidator.cs b/Finch/Validation/Validators/CultureValidator.cs similarity index 94% rename from zero/Validation/Validators/CultureValidator.cs rename to Finch/Validation/Validators/CultureValidator.cs index bf51e577..5a1b6858 100644 --- a/zero/Validation/Validators/CultureValidator.cs +++ b/Finch/Validation/Validators/CultureValidator.cs @@ -1,7 +1,7 @@ using FluentValidation.Validators; using System.Globalization; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public class CultureValidator : PropertyValidator { diff --git a/zero/Validation/Validators/EmailValidator.cs b/Finch/Validation/Validators/EmailValidator.cs similarity index 95% rename from zero/Validation/Validators/EmailValidator.cs rename to Finch/Validation/Validators/EmailValidator.cs index c2aab460..0178541a 100644 --- a/zero/Validation/Validators/EmailValidator.cs +++ b/Finch/Validation/Validators/EmailValidator.cs @@ -1,7 +1,7 @@ using FluentValidation.Validators; using System.Net.Mail; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public class EmailValidator : PropertyValidator, IEmailValidator { diff --git a/zero/Validation/Validators/EmailsValidator.cs b/Finch/Validation/Validators/EmailsValidator.cs similarity index 95% rename from zero/Validation/Validators/EmailsValidator.cs rename to Finch/Validation/Validators/EmailsValidator.cs index 67f57d13..e9399b9d 100644 --- a/zero/Validation/Validators/EmailsValidator.cs +++ b/Finch/Validation/Validators/EmailsValidator.cs @@ -1,6 +1,6 @@ using FluentValidation.Validators; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public class EmailsValidator : PropertyValidator, IEmailValidator { diff --git a/zero/Validation/Validators/HexValidator.cs b/Finch/Validation/Validators/HexValidator.cs similarity index 86% rename from zero/Validation/Validators/HexValidator.cs rename to Finch/Validation/Validators/HexValidator.cs index f6b990af..a1c2a79a 100644 --- a/zero/Validation/Validators/HexValidator.cs +++ b/Finch/Validation/Validators/HexValidator.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public class HexValidator : RegexValidator { diff --git a/zero/Validation/Validators/RegexValidator.cs b/Finch/Validation/Validators/RegexValidator.cs similarity index 95% rename from zero/Validation/Validators/RegexValidator.cs rename to Finch/Validation/Validators/RegexValidator.cs index ee7b3032..54171946 100644 --- a/zero/Validation/Validators/RegexValidator.cs +++ b/Finch/Validation/Validators/RegexValidator.cs @@ -1,7 +1,7 @@ using FluentValidation.Validators; using System.Text.RegularExpressions; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public abstract class RegexValidator : PropertyValidator { diff --git a/zero/Validation/Validators/UrlValidator.cs b/Finch/Validation/Validators/UrlValidator.cs similarity index 92% rename from zero/Validation/Validators/UrlValidator.cs rename to Finch/Validation/Validators/UrlValidator.cs index 1a636ef7..06745f52 100644 --- a/zero/Validation/Validators/UrlValidator.cs +++ b/Finch/Validation/Validators/UrlValidator.cs @@ -1,6 +1,6 @@ using FluentValidation.Validators; -namespace zero.Validation.Validators; +namespace Finch.Validation.Validators; public class UrlValidator : PropertyValidator { diff --git a/readme.md b/readme.md index 5f282702..2d94b149 100644 --- a/readme.md +++ b/readme.md @@ -1 +1 @@ - \ No newline at end of file +finch. \ No newline at end of file diff --git a/zero.Sqlite/Operations/IEntityModifiedHandler.cs b/zero.Sqlite/Operations/IEntityModifiedHandler.cs deleted file mode 100644 index bbfb1d28..00000000 --- a/zero.Sqlite/Operations/IEntityModifiedHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Threading.Tasks; -using zero.Communication; -using zero.Models; - -namespace zero.Sqlite; - -public interface IEntityModifiedHandler : IHandler -{ - Task Saved(T model, bool update) where T : ZeroIdEntity, new() => update ? Updated(model) : Created(model); - Task Created(T model) where T : ZeroIdEntity, new(); - Task Updated(T model) where T : ZeroIdEntity, new(); - Task Deleted(T model) where T : ZeroIdEntity, new(); -} - - -public class EmptyEntityModifiedHandler : IEntityModifiedHandler -{ - public Task Created(T model) where T : ZeroIdEntity, new() => Task.CompletedTask; - public Task Updated(T model) where T : ZeroIdEntity, new() => Task.CompletedTask; - public Task Deleted(T model) where T : ZeroIdEntity, new() => Task.CompletedTask; -} \ No newline at end of file diff --git a/zero.Sqlite/Operations/StoreContext.cs b/zero.Sqlite/Operations/StoreContext.cs deleted file mode 100644 index 2b926213..00000000 --- a/zero.Sqlite/Operations/StoreContext.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using zero.Communication; -using zero.Configuration; -using zero.Context; - -namespace zero.Sqlite; - -public class StoreContext -{ - public IZeroContext Context { get; private set; } - - public IZeroOptions Options { get; private set; } - - public IServiceProvider Services { get; private set; } - - public IMessageAggregator Messages { get; private set; } - - - public StoreContext(IZeroContext context, IServiceProvider serviceProvider, IMessageAggregator messages) - { - Options = context.Options; - Context = context; - Services = serviceProvider; - Messages = messages; - } -} \ No newline at end of file diff --git a/zero/Assemblies/ZeroAssemblyDiscoveryRule.cs b/zero/Assemblies/ZeroAssemblyDiscoveryRule.cs deleted file mode 100644 index cdbfa41b..00000000 --- a/zero/Assemblies/ZeroAssemblyDiscoveryRule.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Extensions.DependencyModel; - -namespace zero.Assemblies; - -public class ZeroAssemblyDiscoveryRule : IAssemblyDiscoveryRule -{ - const string ZeroPrefix = "zero."; - - /// - public bool IsValid(RuntimeLibrary library, AssemblyDiscoveryContext context) - { - StringComparison casing = StringComparison.OrdinalIgnoreCase; - // TODO we need to auto-add assemblies and discover their types which have implementations of IZeroPlugin - return library.Name.StartsWith(ZeroPrefix, casing) || (context.HasEntryAssembly && library.Name.Contains(context.EntryAssemblyName, casing)); - } -} \ No newline at end of file diff --git a/zero/Communication/Handlers/IHandler.cs b/zero/Communication/Handlers/IHandler.cs deleted file mode 100644 index c2ea5d02..00000000 --- a/zero/Communication/Handlers/IHandler.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace zero.Communication; - -public interface IHandler -{ -} diff --git a/zero/Configuration/IZeroCollectionOptions.cs b/zero/Configuration/IZeroCollectionOptions.cs deleted file mode 100644 index 1bd70b9e..00000000 --- a/zero/Configuration/IZeroCollectionOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace zero.Configuration; - -public interface IZeroCollectionOptions -{ - -} \ No newline at end of file diff --git a/zero/Context/ZeroContextMiddleware.cs b/zero/Context/ZeroContextMiddleware.cs deleted file mode 100644 index c1325774..00000000 --- a/zero/Context/ZeroContextMiddleware.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Http; - -namespace zero.Context -{ - public class ZeroContextMiddleware - { - RequestDelegate _next; - - public ZeroContextMiddleware(RequestDelegate next) - { - _next = next; - } - - public async Task Invoke(HttpContext httpContext, IZeroContext zeroContext) - { - await zeroContext.Resolve(httpContext); - await _next(httpContext); - } - } -} diff --git a/zero/FileStorage/FileSystemOptions.cs b/zero/FileStorage/FileSystemOptions.cs deleted file mode 100644 index 97c25f95..00000000 --- a/zero/FileStorage/FileSystemOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace zero.FileStorage; - -public class FileSystemOptions -{ - public string ZeroAssetsPath { get; set; } -} \ No newline at end of file diff --git a/zero/Models/ZeroReference.cs b/zero/Models/ZeroReference.cs deleted file mode 100644 index a8808e26..00000000 --- a/zero/Models/ZeroReference.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace zero.Models; - -public class ZeroReference -{ - public ZeroReference() { } - - public ZeroReference(ZeroEntity entity) - { - Id = entity.Id; - Name = entity.Name; - } - - public static ZeroReference From(ZeroEntity entity) - { - return entity == null ? null : new ZeroReference(entity); - } - - public static ZeroReference From(T entity, Func transform) where T : ZeroEntity - { - return entity == null ? null : new ZeroReference() - { - Id = entity.Id, - Name = transform(entity) - }; - } - - public string Id { get; set; } - - public string Name { get; set; } -} diff --git a/zero/Mvc/ZeroApiController.cs b/zero/Mvc/ZeroApiController.cs deleted file mode 100644 index 57c004bc..00000000 --- a/zero/Mvc/ZeroApiController.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; - -namespace zero.Mvc; - -[ApiController] -public abstract class ZeroApiController : ControllerBase -{ - IZeroContext _context; - public IZeroContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService()); -} \ No newline at end of file diff --git a/zero/Mvc/ZeroController.cs b/zero/Mvc/ZeroController.cs deleted file mode 100644 index 8a7932d8..00000000 --- a/zero/Mvc/ZeroController.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; - -namespace zero.Mvc; - -public abstract class ZeroController : Controller -{ - IZeroContext _context; - public IZeroContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService()); -} \ No newline at end of file diff --git a/zero/ServiceCollectionExtensions.cs b/zero/ServiceCollectionExtensions.cs deleted file mode 100644 index f854e89b..00000000 --- a/zero/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace zero; - -public static class ServiceCollectionExtensions -{ - public static ZeroBuilder AddZero(this IServiceCollection services, IConfiguration configuration) - { - return new ZeroBuilder(services, configuration, null); - } - - public static ZeroBuilder AddZero(this IServiceCollection services, IConfiguration configuration, Action setupAction) - { - return new ZeroBuilder(services, configuration, setupAction); - } -} \ No newline at end of file diff --git a/zero/Usings.cs b/zero/Usings.cs deleted file mode 100644 index d36137d7..00000000 --- a/zero/Usings.cs +++ /dev/null @@ -1,22 +0,0 @@ - -global using System; -global using System.Collections; -global using System.Collections.Generic; -global using System.Linq; -global using System.Threading; -global using System.Threading.Tasks; - -//global using zero.Persistence; -global using zero.Utils; -global using zero.Configuration; -global using zero.Extensions; -global using zero.FileStorage; -global using zero.Models; -global using zero.Modules; -global using zero.Media; -global using zero.Rendering; -global using zero.Validation; -global using zero.Localization; -global using zero.Context; -global using zero.Communication; -global using zero.Assemblies;