Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #85

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<MicrosoftPackageVersion6>6.0.32</MicrosoftPackageVersion6>
<MicrosoftPackageVersion7>7.0.20</MicrosoftPackageVersion7>
<MicrosoftPackageVersion8>8.0.8</MicrosoftPackageVersion8>
<GrpcAspNetCoreVersion>2.65.0</GrpcAspNetCoreVersion>
<GrpcAspNetCoreVersion>2.66.0</GrpcAspNetCoreVersion>
<QuartzVersion>3.13.0</QuartzVersion>
</PropertyGroup>
<ItemGroup>
Expand All @@ -14,19 +14,19 @@
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Autofac.Extras.DynamicProxy" Version="7.1.0" />
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.21.2" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.22.1" />
<PackageVersion Include="Castle.Core" Version="5.1.1" />
<PackageVersion Include="Consul" Version="1.6.10.9" />
<PackageVersion Include="FluentValidation" Version="11.9.2" />
<PackageVersion Include="FluentValidation" Version="11.10.0" />
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<PackageVersion Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" />
<PackageVersion Include="Mapster" Version="7.4.0" />
<PackageVersion Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageVersion Include="MediatR" Version="12.1.1" />
<PackageVersion Include="MediatR.Contracts" Version="2.0.1" />
<PackageVersion Include="mongocsharpdriver" Version="2.28.0" />
<PackageVersion Include="mongocsharpdriver" Version="2.29.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Polly" Version="8.4.1" />
<PackageVersion Include="Polly" Version="8.4.2" />
<PackageVersion Include="protobuf-net" Version="3.1.33" />
<PackageVersion Include="Quartz" Version="$(QuartzVersion)" />
<PackageVersion Include="Quartz.Extensions.DependencyInjection" Version="$(QuartzVersion)" />
Expand All @@ -35,14 +35,14 @@
<PackageVersion Include="Refit" Version="6.3.2" />
<PackageVersion Include="Refit.HttpClientFactory" Version="6.3.2" />
<PackageVersion Include="Refit.Newtonsoft.Json" Version="6.3.2" />
<PackageVersion Include="Serilog" Version="4.0.1" />
<PackageVersion Include="Serilog" Version="4.0.2" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageVersion Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageVersion Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageVersion Include="Serilog.Sinks.Email" Version="4.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.14" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.16" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.8.0" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
Expand Down Expand Up @@ -112,7 +112,7 @@
<!-- Grpc -->
<ItemGroup>
<PackageVersion Include="Google.Api.CommonProtos" Version="2.12.0" />
<PackageVersion Include="Google.Protobuf" Version="3.28.0" />
<PackageVersion Include="Google.Protobuf" Version="3.28.2" />
<PackageVersion Include="Grpc" Version="2.46.6" />
<PackageVersion Include="Grpc.AspNetCore" Version="$(GrpcAspNetCoreVersion)" />
<PackageVersion Include="Grpc.AspNetCore.HealthChecks" Version="$(GrpcAspNetCoreVersion)" />
Expand All @@ -126,17 +126,17 @@
<!-- Tests -->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Xunit.DependencyInjection" Version="9.3.0" />
<PackageVersion Include="Xunit.DependencyInjection" Version="9.4.0" />
<PackageVersion Include="Xunit.DependencyInjection.Logging" Version="9.0.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/Euonia.Application/Behaviors/BearerTokenBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<CommandResponse> HandleAsync(IRoutedMessage context, PipelineD
{
if (!string.IsNullOrWhiteSpace(value) && value.StartsWith("Bearer") && !value.Equals("Bearer null", StringComparison.OrdinalIgnoreCase))
{
context.Metadata.Set("$nerosoft:token", value);
context.Metadata.Set("Authorization", value);
}
}

Expand Down
3 changes: 3 additions & 0 deletions Source/Euonia.Application/Behaviors/UserPrincipalBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public async Task<CommandResponse> HandleAsync(IRoutedMessage context, PipelineD
context.Metadata.Set("$nerosoft:user.tenant", _user.Tenant);
}

{
}

return await next(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static IServiceCollection AddApplicationService(this IServiceCollection s
/// <param name="services">The <see cref="IServiceCollection"/> instance of current application.</param>
/// <param name="definedTypes">The application service types.</param>
/// <returns></returns>
/// <remarks>The application service type should inherits from <see cref="IApplicationService"/>.</remarks>
/// <remarks>The application service type should inherit from <see cref="IApplicationService"/>.</remarks>
public static IServiceCollection AddApplicationService(this IServiceCollection services, IEnumerable<Type> definedTypes)
{
if (!definedTypes.Any())
Expand Down
2 changes: 1 addition & 1 deletion Source/Euonia.Business/Factory/ObjectReflector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private static Tuple<Type, bool> FindServiceType(string name, Type type, bool? m
throw new NotSupportedException($"Can not inject property '{name}', the property type {type.FullName} is not supported.");
}

var @interface = type.GetInterface("IEnumerable");
var @interface = type.GetInterface(nameof(IEnumerable));
if (@interface == null)
{
return Tuple.Create(type, multiple ?? false);
Expand Down
74 changes: 43 additions & 31 deletions Source/Euonia.Caching.Memory/MemoryCacheExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,47 @@ namespace Nerosoft.Euonia.Caching.Memory;
/// </summary>
internal static class MemoryCacheExtensions
{
/// <summary>
/// Extension method to check if a key exists in the given <paramref name="cache"/> instance.
/// </summary>
/// <param name="cache">The cache instance.</param>
/// <param name="key">The key.</param>
/// <returns><c>True</c> if the key exists.</returns>
public static bool Contains(this MemoryCache cache, object key)
{
return cache.TryGetValue(key, out _);
}

internal static void RegisterChild(this MemoryCache cache, object parentKey, object childKey)
{
if (cache.TryGetValue(parentKey, out var keys))
{
var keySet = (ConcurrentDictionary<object, bool>)keys;
keySet.TryAdd(childKey, true);
}
}

internal static void RemoveChilds(this MemoryCache cache, object region)
{
if (cache.TryGetValue(region, out var keys))
{
var keySet = (ConcurrentDictionary<object, bool>)keys;
foreach (var key in keySet.Keys)
{
cache.Remove(key);
}
}
}
/// <summary>
/// Extension method to check if a key exists in the given <paramref name="cache"/> instance.
/// </summary>
/// <param name="cache">The cache instance.</param>
/// <param name="key">The key.</param>
/// <returns><c>True</c> if the key exists.</returns>
public static bool Contains(this IMemoryCache cache, object key)
{
return cache.TryGetValue(key, out _);
}

internal static void RegisterChild(this IMemoryCache cache, object parentKey, object childKey)
{
if (!cache.TryGetValue(parentKey, out var keys))
{
return;
}

if (keys is not ConcurrentDictionary<object, bool> keySet)
{
throw new InvalidOperationException("The parent key is not a valid key set.");
}

keySet.TryAdd(childKey, true);
}

internal static void RemoveChildren(this IMemoryCache cache, object region)
{
if (!cache.TryGetValue(region, out var keys))
{
return;
}

if (keys is not ConcurrentDictionary<object, bool> keySet)
{
return;
}

foreach (var key in keySet.Keys)
{
cache.Remove(key);
}
}
}
2 changes: 1 addition & 1 deletion Source/Euonia.Caching.Memory/MemoryCacheHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void Clear()
/// <inheritdoc/>
public override void ClearRegion(string region)
{
_cache.RemoveChilds(region);
_cache.RemoveChildren(region);
_cache.Remove(region);
}

Expand Down
Loading
Loading