forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify DI Support (ChilliCream#6994)
- Loading branch information
1 parent
717ded9
commit 4450784
Showing
100 changed files
with
1,018 additions
and
2,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.202", | ||
"version": "8.0.101", | ||
"rollForward": "latestMajor" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/HotChocolate/Core/src/Abstractions/ScopedServiceAttribute.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
...re/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.ResolverCompiler.cs
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...olate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Services.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using HotChocolate.Execution.Configuration; | ||
using HotChocolate.Resolvers; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Microsoft.Extensions.DependencyInjection; | ||
|
||
public static partial class RequestExecutorBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Adds a initializer to copy state between a request scoped service instance and | ||
/// a resolver scoped service instance. | ||
/// </summary> | ||
/// <param name="builder"> | ||
/// The request executor builder. | ||
/// </param> | ||
/// <param name="initializer"> | ||
/// The initializer that is used to initialize the service scope. | ||
/// </param> | ||
/// <typeparam name="TService"> | ||
/// The type of the service that shall be initialized. | ||
/// </typeparam> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// The <paramref name="builder"/> is <c>null</c>. | ||
/// </exception> | ||
public static IRequestExecutorBuilder AddScopedServiceInitializer<TService>( | ||
this IRequestExecutorBuilder builder, | ||
Action<TService, TService> initializer) | ||
{ | ||
if (builder == null) | ||
{ | ||
throw new ArgumentNullException(nameof(builder)); | ||
} | ||
|
||
if (initializer == null) | ||
{ | ||
throw new ArgumentNullException(nameof(initializer)); | ||
} | ||
|
||
builder.Services.AddSingleton<IServiceScopeInitializer>(new DelegateServiceInitializer<TService>(initializer)); | ||
return builder; | ||
} | ||
} | ||
|
||
file sealed class DelegateServiceInitializer<TService>( | ||
Action<TService, TService> initializer) | ||
: ServiceInitializer<TService> | ||
{ | ||
private readonly Action<TService, TService> _initializer = initializer ?? | ||
throw new ArgumentNullException(nameof(initializer)); | ||
|
||
protected override void Initialize(TService requestScopeService, TService resolverScopeService) | ||
=> _initializer(requestScopeService, resolverScopeService); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.