src/NetCoreApp/YLControllers/BaseController.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Security.Claims;
using YL.Core.Dto;
using YL.Utils.Extensions;
using YL.Utils.Json;
using YL.Utils.Table;
namespace YL.NetCore.NetCoreApp
{
/// <summary>
///[FromBody] 请求正文 只能有一个参数 json 针对复杂类型参数进行推断
///[FromForm] 请求正文中的表单数据
///[FromHeader] 请求标头
///[FromQuery] 请求查询字符串参数
///[FromRoute] 当前请求中的路由数据
///[FromServices] 作为操作参数插入的请求服务
/// url:https://docs.microsoft.com/zh-cn/aspnet/core/web-api/?view=aspnetcore-2.1
/// </summary>
[Authorize]
public class BaseController : Controller
{
private IMemoryCache _memory;
private IConfiguration _configuration;
public string AppRoot
{ get { return CreateService<IWebHostEnvironment>().ContentRootPath; } }
public string WebRoot
{ get { return CreateService<IWebHostEnvironment>().WebRootPath; } }
protected IMemoryCache GetMemoryCache
{
get
{
if (_memory == null)
{
_memory = CreateService<IMemoryCache>();
return _memory;
}
return _memory;
}
}
public List<string> GetCacheKeys()
{
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
var entries = GetMemoryCache.GetType().GetField("_entries", flags).GetValue(GetMemoryCache);
var keys = new List<string>();
if (!(entries is IDictionary cacheItems)) return keys;
foreach (DictionaryEntry cacheItem in cacheItems)
{
后面还有 203 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。