尝试移除part

This commit is contained in:
Sanchime 2022-11-27 18:05:18 +08:00
parent 15904e0ed0
commit 6c23330c62
13 changed files with 46 additions and 65 deletions

View File

@ -1,14 +1,4 @@
using Dipper.Alioth.Options; namespace Dipper.Alioth.Extensions;
using Dipper.Alioth.Providers;
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Dipper.Alioth.Web;
public static class StarletExtension public static class StarletExtension
{ {
@ -64,7 +54,7 @@ public static class StarletExtension
manager.ApplicationParts.Add(new AssemblyPart(assembly)); manager.ApplicationParts.Add(new AssemblyPart(assembly));
} }
manager.FeatureProviders.Add(new ApiFeatureProvider()); manager.FeatureProviders.Add(new Providers.StarletFeatureProvider());
}); });
builder.Services.Configure<MvcOptions>(options => builder.Services.Configure<MvcOptions>(options =>

View File

@ -1,5 +1,3 @@
using Dipper.Alioth.Web;
namespace Dipper.Alioth.Extensions; namespace Dipper.Alioth.Extensions;
public static class StartHostExtension public static class StartHostExtension

View File

@ -0,0 +1,11 @@
global using Dipper.Alioth.Options;
global using Dipper.Alioth.Providers;
global using Dipper.Alioth.Starlets;
global using Dipper.Alioth.Web;
global using Dipper.Alioth.Extensions;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.ApplicationParts;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;

View File

@ -1,20 +0,0 @@
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
namespace Dipper.Alioth;
public class ManagerStarlet : IStarlet
{
private ApplicationPartManager _partManager;
public ManagerStarlet(ApplicationPartManager partManager)
{
_partManager = partManager;
}
public IEnumerable<string> GetList()
{
return _partManager.ApplicationParts.Select(x => x.Name);
}
}

View File

@ -1,6 +1,3 @@
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Mvc;
namespace Dipper.Alioth.Options; namespace Dipper.Alioth.Options;
public class StarOption public class StarOption

View File

@ -1,10 +1,9 @@
using System.Reflection; using System.Reflection;
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Controllers;
namespace Dipper.Alioth.Providers; namespace Dipper.Alioth.Providers;
public class ApiFeatureProvider : ControllerFeatureProvider public class StarletFeatureProvider : ControllerFeatureProvider
{ {
protected override bool IsController(TypeInfo typeInfo) protected override bool IsController(TypeInfo typeInfo)
{ {

View File

@ -1,6 +1,4 @@
using Dipper.Alioth.Starlets; namespace Dipper.Alioth.Services;
namespace Dipper.Alioth;
public class DomainAsterism : IAsterism public class DomainAsterism : IAsterism
{ {

View File

@ -0,0 +1,28 @@
namespace Dipper.Alioth.Services;
public class ManagerStarlet : IStarlet
{
private readonly ApplicationPartManager _partManager;
public ManagerStarlet(ApplicationPartManager partManager)
{
_partManager = partManager;
}
public IEnumerable<string> GetList()
{
return _partManager.ApplicationParts.Select(x => x.Name);
}
public bool Remove(string name)
{
var part = _partManager.ApplicationParts.FirstOrDefault(part => part.Name == name);
if (part is null)
{
return false;
}
return _partManager.ApplicationParts.Remove(part);
}
}

View File

@ -1,5 +1,3 @@
using Dipper.Alioth.Options;
namespace Dipper.Alioth; namespace Dipper.Alioth;
public abstract class StarHost public abstract class StarHost
@ -7,6 +5,4 @@ public abstract class StarHost
public abstract void Run(string[] args, Action<StarOption> action); public abstract void Run(string[] args, Action<StarOption> action);
public abstract Task RunAsync(string[] args, Action<StarOption> action); public abstract Task RunAsync(string[] args, Action<StarOption> action);
} }

View File

@ -1,6 +1,4 @@
using System.Text; using System.Text;
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ActionConstraints; using Microsoft.AspNetCore.Mvc.ActionConstraints;
using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.ApplicationModels;

View File

@ -1,14 +0,0 @@
using System.Reflection;
using Dipper.Alioth.Starlets;
using Microsoft.AspNetCore.Mvc.Controllers;
namespace Dipper.Alioth.Web;
public class StarletFeatureProvider : ControllerFeatureProvider
{
protected override bool IsController(TypeInfo typeInfo)
{
return typeof(IStarlet).IsAssignableFrom(typeInfo) && typeInfo.IsPublic
&& !typeInfo.IsAbstract && !typeInfo.IsGenericType;
}
}

View File

@ -1,6 +1,4 @@
using Dipper.Alioth.Options;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace Dipper.Alioth.Web; namespace Dipper.Alioth.Web;

View File

@ -1,4 +1,6 @@
using Dipper.Alioth; using Dipper.Alioth;
using Dipper.Alioth.Extensions;
using Dipper.Alioth.Services;
using Dipper.Alioth.Web; using Dipper.Alioth.Web;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);