2021-07-04 01:41:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Sheng.Winform.Controls.Kernal
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public class FieldAccessorPool : FastReflectionPool<string,IFieldAccessor>
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
protected override IFieldAccessor Create(Type type, string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (type == null || String.IsNullOrEmpty(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Assert(false, "type 或 key 为空");
|
|
|
|
|
|
throw new ArgumentNullException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FieldInfo fieldInfo = type.GetField(key);
|
|
|
|
|
|
|
|
|
|
|
|
if (fieldInfo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Assert(false, "没有指定的FieldInfo:" + key);
|
|
|
|
|
|
throw new MissingFieldException(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new FieldAccessor(fieldInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|