blob: 2c24c610ce00633b7e15dbf946f0f13231d1ac64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using System;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
namespace StardewModdingAPI.Web.Framework
{
/// <summary>Discovers controllers with support for non-public controllers.</summary>
internal class InternalControllerFeatureProvider : ControllerFeatureProvider
{
/*********
** Public methods
*********/
/// <summary>Determines if a given type is a controller.</summary>
/// <param name="type">The <see cref="T:System.Reflection.TypeInfo" /> candidate.</param>
/// <returns><code>true</code> if the type is a controller; otherwise <code>false</code>.</returns>
protected override bool IsController(TypeInfo type)
{
return
type.IsClass
&& !type.IsAbstract
&& (/*type.IsPublic &&*/ !type.ContainsGenericParameters)
&& (!type.IsDefined(typeof(NonControllerAttribute))
&& (type.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase) || type.IsDefined(typeof(ControllerAttribute))));
}
}
}
|