using System.Reflection; namespace Siggingway; internal interface IFieldOrPropertyInfo { string Name { get; } Type ActualType { get; } void SetValue(object? self, object? value); T? GetCustomAttribute() where T : Attribute; } internal sealed class FieldInfoWrapper : IFieldOrPropertyInfo { private FieldInfo Info { get; } public FieldInfoWrapper(FieldInfo info) { this.Info = info; } public string Name => this.Info.Name; public Type ActualType => this.Info.FieldType; public void SetValue(object? self, object? value) { this.Info.SetValue(self, value); } public T? GetCustomAttribute() where T : Attribute { return this.Info.GetCustomAttribute(); } } internal sealed class PropertyInfoWrapper : IFieldOrPropertyInfo { private PropertyInfo Info { get; } public PropertyInfoWrapper(PropertyInfo info) { this.Info = info; } public string Name => this.Info.Name; public Type ActualType => this.Info.PropertyType; public void SetValue(object? self, object? value) { this.Info.SetValue(self, value); } public T? GetCustomAttribute() where T : Attribute { return this.Info.GetCustomAttribute(); } }