Skip to content

Class ClassFieldDispatcher

Namespace: Tool.Utils.ActionDelegate
Assembly: Tool.Net.dll

类中字段赋值,创建一个委托,实现类调用,提高性能 (赋值/取值)

csharp
public class ClassFieldDispatcher

Inheritance

objectClassFieldDispatcher

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks

代码由逆血提供支持

Constructors

ClassFieldDispatcher(Type, ClassField)

根据类,创建对象委托

csharp
public ClassFieldDispatcher(Type classtype, ClassField classField = ClassField.All)

Parameters

classtype Type

类对象类型

classField ClassField

默认读取所有行为

ClassFieldDispatcher(Type, ClassField, PropertyInfo[])

根据类,创建对象委托

csharp
public ClassFieldDispatcher(Type classtype, ClassField classField, PropertyInfo[] properties)

Parameters

classtype Type

类对象类型

classField ClassField

默认读取所有行为

properties PropertyInfo[]

类的指定参数

Properties

Field

覆盖功能

csharp
public ClassField Field { get; }

Property Value

ClassField

KeyParameters

获取当前类所有字段字典

csharp
public IDictionary<string, PropertyInfo> KeyParameters { get; }

Property Value

IDictionary<string, PropertyInfo>

Parameters

类成员(只包含公开的成员,如遇到上层类有意隐藏下层类,只使用上层类成员)

csharp
public PropertyInfo[] Parameters { get; }

Property Value

PropertyInfo[]

Type

实例化对象类型

csharp
public Type Type { get; }

Property Value

Type

Methods

Get(object)

从类中获取所有可读值

csharp
public IDictionary<string, object> Get(object _class)

Parameters

_class object

类对象

Returns

IDictionary<string, object>

返回值集合

GetClassFields(Type, ref PropertyInfo[])

通过构造器,直接获取相关取值委托

csharp
public static ClassFieldDispatcher.GetClassField GetClassFields(Type classtype, ref PropertyInfo[] propertyInfos)

Parameters

classtype Type

propertyInfos PropertyInfo[]

类参数

Returns

ClassFieldDispatcher.GetClassField

取值委托

Set(object, IDictionary<string, object>)

向类传入修改集合

csharp
public void Set(object _class, IDictionary<string, object> parameters)

Parameters

_class object

类对象

parameters IDictionary<string, object>

值集合(字典如标记忽略大小写赋值,就能实现特定行为)

SetClassFields(Type, ref PropertyInfo[])

通过构造器,直接获取相关赋值委托

csharp
public static ClassFieldDispatcher.SetClassField SetClassFields(Type classtype, ref PropertyInfo[] propertyInfos)

Parameters

classtype Type

propertyInfos PropertyInfo[]

类参数

Returns

ClassFieldDispatcher.SetClassField

赋值委托或无法委托因为都是只读

基于Apache-2.0协议开源