Shared/Kernelx.ClientContexts/Contexts/RequestParameterObjectBase.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Kernelx.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Kernelx.Contexts
{
public abstract class RequestParameterObjectBase: IRequestParameter
{
public RequestParameterObjectBase() =>
(ContextWorkload.Current as ClientContextWorkload).SetRequestParameter(this);
private Dictionary<string, object> __data;
private Dictionary<string, object> _GetData()
{
if (__data == null)
{
lock (this)
if (__data == null)
{
__data = new Dictionary<string, object>();
var ps = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var p in ps)
{
if (p.CanRead)
__data[p.Name] = p.GetValue(this,p.GetIndexValues());
}
}
}
return __data;
}
IEnumerable<string> IRequestParameter.Keys => _GetData().Keys;
object IRequestParameter.GetValue(string key)
=> _GetData().ContainsKey(key)
|| _GetData().ContainsKey(key = $"{key.Substring(0, 1).ToLower()}{key.Substring(1)}")
|| _GetData().ContainsKey(key = $"{key.Substring(0, 1).ToUpper()}{key.Substring(1)}")
? _GetData()[key] : null;
private IList<FileWrapper> _files;
IEnumerable<FileWrapper> IRequestParameter.Files => _files;
private const string _file_key = "request_file_{0}";
public object ToRequestObject()
{
try
{
var result = new Dictionary<string, object>(_GetData());
if (_files.Count > 0)
{
for (var i = 0; i < _files.Count; i++)
{
var f = _files[i];
result[string.Format(_file_key, i)] = new { f.FileName, f.ContentType, f.Name, f.Length };
}
}
后面还有 28 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
