32 lines
1009 B
C#
32 lines
1009 B
C#
using JNPF.DependencyInjection;
|
|
using JNPF.Reflection;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace JNPF.VisualDev
|
|
{
|
|
[SuppressSniffer]
|
|
public static class OverideVisualDevServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 添加重写在线开发接口的服务
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddOverideVisualDev(this IServiceCollection services)
|
|
{
|
|
var actions = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IOverideVisualDevService).IsAssignableFrom(u)).ToList();
|
|
foreach (var item in actions)
|
|
{
|
|
var attr = item.GetAttribute<OverideVisualDevAttribute>();
|
|
if (attr != null)
|
|
{
|
|
OverideVisualDevManager.Add(attr.ModelId, item);
|
|
}
|
|
}
|
|
|
|
return services;
|
|
}
|
|
|
|
}
|
|
}
|