Skip to content

Commit fa45525

Browse files
committed
Renaming.
1 parent 1efd99e commit fa45525

File tree

52 files changed

+131
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+131
-77
lines changed

DependencyInjection/src/AppCoreNet.Extensions.DependencyInjection.Abstractions/ServiceCollectionServiceProvider.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
namespace AppCoreNet.Extensions.DependencyInjection;
1111

1212
internal sealed class ServiceCollectionServiceProvider : IServiceProvider
13+
#if NET6_0_OR_GREATER
14+
, IServiceProviderIsService
15+
#endif
1316
{
1417
private readonly IServiceCollection _services;
1518
private readonly Dictionary<Type, object> _additionalServices = new ();
@@ -55,7 +58,7 @@ object ServiceFactory(ServiceDescriptor serviceDescriptor)
5558

5659
public object? GetService(Type serviceType)
5760
{
58-
if (serviceType == typeof(IServiceProvider))
61+
if (serviceType == typeof(IServiceProvider) || serviceType == typeof(IServiceProviderIsService))
5962
return this;
6063

6164
if (_additionalServices.TryGetValue(serviceType, out object? instance))
@@ -79,4 +82,21 @@ object ServiceFactory(ServiceDescriptor serviceDescriptor)
7982

8083
return instance;
8184
}
85+
86+
public bool IsService(Type serviceType)
87+
{
88+
if (serviceType == typeof(IServiceProvider) || serviceType == typeof(IServiceProviderIsService))
89+
return true;
90+
91+
if (_additionalServices.TryGetValue(serviceType, out object? _))
92+
return true;
93+
94+
if (serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
95+
return true;
96+
97+
return _services.Any(
98+
sd => sd.ServiceType == serviceType
99+
|| (serviceType.IsGenericType
100+
&& sd.ServiceType == serviceType.GetGenericTypeDefinition()));
101+
}
82102
}

Hosting/src/AppCoreNet.Extensions.Hosting.Abstractions/HostedServiceServiceCollectionExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Copyright (c) The AppCore .NET project.
33

44
using System;
5-
using AppCoreNet.Extensions.DependencyInjection;
65
using Microsoft.Extensions.DependencyInjection;
76
using Microsoft.Extensions.Hosting;
87

98
// ReSharper disable once CheckNamespace
10-
namespace AppCore.Extensions.DependencyInjection;
9+
namespace AppCoreNet.Extensions.DependencyInjection;
1110

1211
/// <summary>
1312
/// Provides extensions methods to register hosted services with a <see cref="IServiceCollection"/>.

Hosting/src/AppCoreNet.Extensions.Hosting.Abstractions/IStartupTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66

7-
namespace AppCore.Extensions.Hosting;
7+
namespace AppCoreNet.Extensions.Hosting;
88

99
/// <summary>
1010
/// Represents a task that is executed during application startup.
@@ -21,5 +21,5 @@ public interface IStartupTask
2121
/// </summary>
2222
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
2323
/// <returns>A task that represents the asynchronous event operation.</returns>
24-
Task ExecuteAsync(CancellationToken cancellationToken);
24+
Task ExecuteAsync(CancellationToken cancellationToken = default);
2525
}

Hosting/src/AppCoreNet.Extensions.Hosting.Abstractions/StartupTaskServiceCollectionExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33

44
using System;
55
using AppCoreNet.Diagnostics;
6-
using AppCore.Extensions.Hosting;
7-
using AppCoreNet.Extensions.DependencyInjection;
6+
using AppCoreNet.Extensions.Hosting;
87
using Microsoft.Extensions.DependencyInjection;
98
using Microsoft.Extensions.DependencyInjection.Extensions;
109

1110
// ReSharper disable once CheckNamespace
12-
namespace AppCore.Extensions.DependencyInjection;
11+
namespace AppCoreNet.Extensions.DependencyInjection;
1312

1413
/// <summary>
1514
/// Provides extensions methods to register startup tasks with a <see cref="IServiceCollection"/>.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/IPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Reflection;
66

7-
namespace AppCore.Extensions.Hosting.Plugins;
7+
namespace AppCoreNet.Extensions.Hosting.Plugins;
88

99
/// <summary>
1010
/// Represents a plugin.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/IPluginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66

7-
namespace AppCore.Extensions.Hosting.Plugins;
7+
namespace AppCoreNet.Extensions.Hosting.Plugins;
88

99
/// <summary>
1010
/// Represents the plugin manager.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/IPluginService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT license.
22
// Copyright (c) The AppCore .NET project.
33

4-
namespace AppCore.Extensions.Hosting.Plugins;
4+
namespace AppCoreNet.Extensions.Hosting.Plugins;
55

66
/// <summary>
77
/// Represents a plugin service.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/IPluginServiceCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Generic;
22

3-
namespace AppCore.Extensions.Hosting.Plugins;
3+
namespace AppCoreNet.Extensions.Hosting.Plugins;
44

55
/// <summary>
66
/// Represents a collection of plugin services.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/PluginInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT license.
22
// Copyright (c) The AppCore .NET project.
33

4-
namespace AppCore.Extensions.Hosting.Plugins;
4+
namespace AppCoreNet.Extensions.Hosting.Plugins;
55

66
/// <summary>
77
/// Provides information about a plugin.

Hosting/src/AppCoreNet.Extensions.Hosting.Plugins.Abstractions/PluginManagerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using AppCoreNet.Diagnostics;
55

6-
namespace AppCore.Extensions.Hosting.Plugins;
6+
namespace AppCoreNet.Extensions.Hosting.Plugins;
77

88
/// <summary>
99
/// Provides extensions methods for the <seealso cref="IPluginManager"/>.

0 commit comments

Comments
 (0)