Skip to content

Commit

Permalink
Updated packages. (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored May 28, 2022
1 parent 4292785 commit 80ffe72
Show file tree
Hide file tree
Showing 70 changed files with 218 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Entity" Version="6.0.16" />
<PackageReference Include="Fluxera.Extensions.Validation.Abstractions" Version="6.0.29" />
<PackageReference Include="Fluxera.Entity" Version="6.1.0" />
<PackageReference Include="Fluxera.Extensions.Validation.Abstractions" Version="6.0.33" />
<PackageReference Include="Fluxera.Linq.Expressions" Version="6.0.11" />
<PackageReference Include="Fluxera.ValueObject" Version="6.0.10" />
<PackageReference Include="Fluxera.ValueObject" Version="6.1.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 2 additions & 0 deletions src/Fluxera.Repository.Abstractions/IReadOnlyRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Fluxera.Repository
{
using System;
using Fluxera.Entity;
using Fluxera.Repository.Traits;
using JetBrains.Annotations;
Expand All @@ -18,6 +19,7 @@ public interface IReadOnlyRepository<TAggregateRoot, TKey> : IDisposableReposito
ICanFind<TAggregateRoot, TKey>,
ICanAggregate<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
}
}
2 changes: 2 additions & 0 deletions src/Fluxera.Repository.Abstractions/IRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Fluxera.Repository
{
using System;
using Fluxera.Entity;
using Fluxera.Repository.Traits;
using JetBrains.Annotations;
Expand All @@ -20,6 +21,7 @@ public interface IRepository<TAggregateRoot, TKey> :
ICanRemove<TAggregateRoot, TKey>,
IReadOnlyRepository<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface IInterceptor
[PublicAPI]
public interface IInterceptor<TAggregateRoot, TKey> : IInterceptor
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Gets the order of execution for this interceptor. The higher, the later this interceptor executes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[PublicAPI]
public abstract class InterceptorBase<TAggregateRoot, TKey> : IInterceptor<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <inheritdoc />
public virtual int Order => 0;
Expand All @@ -27,36 +28,18 @@ public virtual Task BeforeAddAsync(TAggregateRoot item, InterceptionEvent e)
return Task.CompletedTask;
}

///// <inheritdoc />
//public virtual Task AfterAddAsync(TAggregateRoot item)
//{
// return Task.CompletedTask;
//}

/// <inheritdoc />
public virtual Task BeforeUpdateAsync(TAggregateRoot item, InterceptionEvent e)
{
return Task.CompletedTask;
}

///// <inheritdoc />
//public virtual Task AfterUpdateAsync(TAggregateRoot item)
//{
// return Task.CompletedTask;
//}

/// <inheritdoc />
public virtual Task BeforeRemoveAsync(TAggregateRoot item, InterceptionEvent e)
{
return Task.CompletedTask;
}

/// <inheritdoc />
//public virtual Task AfterRemoveAsync(TAggregateRoot item)
//{
// return Task.CompletedTask;
//}

/// <inheritdoc />
public virtual Task<Expression<Func<TAggregateRoot, bool>>> BeforeRemoveRangeAsync(Expression<Func<TAggregateRoot, bool>> predicate, InterceptionEvent e)
{
Expand All @@ -80,29 +63,5 @@ public virtual Task<ISpecification<TAggregateRoot>> BeforeFindAsync(ISpecificati
{
return Task.FromResult(specification);
}

///// <inheritdoc />
//public virtual Task AfterFindAsync(TAggregateRoot item)
//{
// return Task.CompletedTask;
//}

///// <inheritdoc />
//public virtual Task AfterFindAsync(IReadOnlyCollection<TAggregateRoot> items)
//{
// return Task.CompletedTask;
//}

///// <inheritdoc />
//public virtual Task AfterFindAsync<TResult>(TResult item)
//{
// return Task.CompletedTask;
//}

///// <inheritdoc />
//public virtual Task AfterFindAsync<TResult>(IReadOnlyCollection<TResult> items)
//{
// return Task.CompletedTask;
//}
}
}
1 change: 1 addition & 0 deletions src/Fluxera.Repository.Abstractions/ReadOnlyRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
/// <typeparam name="TKey"></typeparam>
public abstract class ReadOnlyRepository<TAggregateRoot, TKey> : IReadOnlyRepository<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
private readonly IReadOnlyRepository<TAggregateRoot, TKey> innerRepository;

Expand Down
1 change: 1 addition & 0 deletions src/Fluxera.Repository.Abstractions/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/// <typeparam name="TKey"></typeparam>
public abstract class Repository<TAggregateRoot, TKey> : ReadOnlyRepository<TAggregateRoot, TKey>, IRepository<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
private readonly IRepository<TAggregateRoot, TKey> innerRepository;

Expand Down
12 changes: 3 additions & 9 deletions src/Fluxera.Repository.Abstractions/RepositoryName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ public sealed class RepositoryName : PrimitiveValueObject<RepositoryName, string
/// Creates a new instance of the <see cref="RepositoryName" /> type.
/// </summary>
/// <param name="name"></param>
public RepositoryName(string name)
public RepositoryName(string name) : base(name)
{
Guard.Against.NullOrWhiteSpace(name, nameof(name));

this.Name = name;
Guard.Against.NullOrWhiteSpace(name);
}

/// <summary>
/// Gets the name of the repository.
/// </summary>
public string Name
{
get => this.Value;
set => this.Value = value;
}
public string Name => this.Value;

/// <summary>
/// Converts the given <see cref="RepositoryName" /> to a <see cref="string" />.
Expand Down
2 changes: 2 additions & 0 deletions src/Fluxera.Repository.Abstractions/Traits/ICanAdd.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Fluxera.Repository.Traits
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -18,6 +19,7 @@
[PublicAPI]
public interface ICanAdd<in TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Adds the given instance to the underlying store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Fluxera.Repository.Traits
[PublicAPI]
public interface ICanAggregate<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Gets the count of existing items of the underlying store.
Expand Down
1 change: 1 addition & 0 deletions src/Fluxera.Repository.Abstractions/Traits/ICanFind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
[PublicAPI]
public interface ICanFind<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Finds the first item that matches the predicate expression.
Expand Down
1 change: 1 addition & 0 deletions src/Fluxera.Repository.Abstractions/Traits/ICanGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
[PublicAPI]
public interface ICanGet<TAggregateRoot, in TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Gets the instance from the underlying store for the given id.
Expand Down
1 change: 1 addition & 0 deletions src/Fluxera.Repository.Abstractions/Traits/ICanRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
[PublicAPI]
public interface ICanRemove<TAggregateRoot, in TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Deletes the given instance from the underlying store.
Expand Down
2 changes: 2 additions & 0 deletions src/Fluxera.Repository.Abstractions/Traits/ICanUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Fluxera.Repository.Traits
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -18,6 +19,7 @@
[PublicAPI]
public interface ICanUpdate<in TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
/// <summary>
/// Updates the given instance in the underlying store.
Expand Down
4 changes: 3 additions & 1 deletion src/Fluxera.Repository.EntityFramework/DbContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public DbContextFactory(IServiceProvider serviceProvider, IRepositoryRegistry re
this.repositoryRegistry = repositoryRegistry;
}

public DbContext CreateDbContext<TAggregateRoot, TKey>() where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
public DbContext CreateDbContext<TAggregateRoot, TKey>()
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
RepositoryName repositoryName = this.repositoryRegistry.GetRepositoryNameFor<TAggregateRoot>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Fluxera.Repository.EntityFrameworkCore
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand All @@ -12,6 +13,7 @@

internal sealed class EntityFrameworkCoreRepository<TAggregateRoot, TKey> : LinqRepositoryBase<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
private readonly DbContext dbContext;
private readonly DbSet<TAggregateRoot> dbSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PropertyGroup>
<Title>Fluxera.Repository.EntityFrameworkCore</Title>
<Description>An EntityFramework Core repository implementation.</Description>
<PackageTags>fluxera;library;extensions;repository;storage;ef;ec-core;entity-framework</PackageTags>
<PackageTags>fluxera;library;extensions;repository;storage;ef;ef-core;entity-framework</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,12 +22,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Enumeration.EntityFrameworkCore" Version="6.0.12" />
<PackageReference Include="Fluxera.Enumeration.EntityFrameworkCore" Version="6.0.13" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/Fluxera.Repository.EntityFramework/IDbContextFactory.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
namespace Fluxera.Repository.EntityFrameworkCore
{
using System;
using Fluxera.Entity;
using Microsoft.EntityFrameworkCore;

internal interface IDbContextFactory
{
DbContext CreateDbContext<TAggregateRoot, TKey>() where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>;
DbContext CreateDbContext<TAggregateRoot, TKey>()
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>;
}
}
21 changes: 11 additions & 10 deletions src/Fluxera.Repository.InMemory/InMemoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

internal sealed class InMemoryRepository<TAggregateRoot, TKey> : LinqRepositoryBase<TAggregateRoot, TKey>
where TAggregateRoot : AggregateRoot<TAggregateRoot, TKey>
where TKey : IComparable<TKey>, IEquatable<TKey>
{
private static readonly ConcurrentDictionary<TKey, TAggregateRoot> store = new ConcurrentDictionary<TKey, TAggregateRoot>();
private static readonly ConcurrentDictionary<TKey, TAggregateRoot> Store = new ConcurrentDictionary<TKey, TAggregateRoot>();

private static string Name => "Fluxera.Repository.InMemoryRepository";

/// <inheritdoc />
protected override IQueryable<TAggregateRoot> Queryable => store.Values.AsQueryable();
protected override IQueryable<TAggregateRoot> Queryable => Store.Values.AsQueryable();

/// <inheritdoc />
public override string ToString()
Expand Down Expand Up @@ -59,7 +60,7 @@ protected override Task<TResult> FirstOrDefaultAsync<TResult>(IQueryable<TResult
protected override Task AddAsync(TAggregateRoot item, CancellationToken cancellationToken)
{
item.ID = GenerateKey();
store.TryAdd(item.ID, item);
Store.TryAdd(item.ID, item);
return Task.CompletedTask;
}

Expand All @@ -69,7 +70,7 @@ protected override Task AddRangeAsync(IEnumerable<TAggregateRoot> items, Cancell
foreach(TAggregateRoot item in items)
{
item.ID = GenerateKey();
store.TryAdd(item.ID, item);
Store.TryAdd(item.ID, item);
}

return Task.CompletedTask;
Expand All @@ -81,7 +82,7 @@ protected override Task RemoveRangeAsync(ISpecification<TAggregateRoot> specific
IQueryable<TAggregateRoot> items = this.Queryable.Where(specification.Predicate);
foreach(TAggregateRoot item in items)
{
store.TryRemove(item.ID, out _);
Store.TryRemove(item.ID, out _);
}

return Task.CompletedTask;
Expand All @@ -92,7 +93,7 @@ protected override Task RemoveRangeAsync(IEnumerable<TAggregateRoot> items, Canc
{
foreach(TAggregateRoot item in items)
{
store.TryRemove(item.ID, out _);
Store.TryRemove(item.ID, out _);
}

return Task.CompletedTask;
Expand All @@ -101,7 +102,7 @@ protected override Task RemoveRangeAsync(IEnumerable<TAggregateRoot> items, Canc
/// <inheritdoc />
protected override Task UpdateAsync(TAggregateRoot item, CancellationToken cancellationToken)
{
store[item.ID] = item;
Store[item.ID] = item;
return Task.CompletedTask;
}

Expand All @@ -110,7 +111,7 @@ protected override Task UpdateRangeAsync(IEnumerable<TAggregateRoot> items, Canc
{
foreach(TAggregateRoot item in items)
{
store[item.ID] = item;
Store[item.ID] = item;
}

return Task.CompletedTask;
Expand All @@ -130,15 +131,15 @@ private static TKey GenerateKey()

if(typeof(TKey) == typeof(int))
{
TKey pkValue = store.Keys.LastOrDefault();
TKey pkValue = Store.Keys.LastOrDefault();

int nextInt = Convert.ToInt32(pkValue) + 1;
return (TKey)Convert.ChangeType(nextInt, typeof(TKey));
}

if(typeof(TKey) == typeof(long))
{
TKey pkValue = store.Keys.LastOrDefault();
TKey pkValue = Store.Keys.LastOrDefault();

int nextInt = Convert.ToInt32(pkValue) + 1;
return (TKey)Convert.ChangeType(nextInt, typeof(TKey));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Enumeration.LiteDB" Version="6.0.12" />
<PackageReference Include="Fluxera.Spatial.LiteDB" Version="6.0.7" />
<PackageReference Include="Fluxera.Enumeration.LiteDB" Version="6.0.13" />
<PackageReference Include="Fluxera.Spatial.LiteDB" Version="6.0.9" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading

0 comments on commit 80ffe72

Please sign in to comment.