This commit is contained in:
2026-06-09 00:38:54 +07:00
parent b8b222632d
commit 466a9fac10
633 changed files with 109442 additions and 229 deletions

View File

@@ -308,9 +308,42 @@ namespace VTabs.Libs
public static T GetFieldValue<T>(this object o, string fieldName, bool exceptionIfNotFound = true) => (T)o.GetFieldValue(fieldName, exceptionIfNotFound);
public static T GetPropertyValue<T>(this object o, string propertyName, bool exceptionIfNotFound = true) => (T)o.GetPropertyValue(propertyName, exceptionIfNotFound);
public static T GetMemberValue<T>(this object o, string memberName, bool exceptionIfNotFound = true) => (T)o.GetMemberValue(memberName, exceptionIfNotFound);
public static T GetFieldValue<T>(this object o, string fieldName, bool exceptionIfNotFound = true)
{
var val = o.GetFieldValue(fieldName, exceptionIfNotFound);
if (val == null) return default;
if (typeof(T) == typeof(List<int>) && val is System.Collections.IEnumerable ienum && !(val is List<int>))
{
var list = new List<int>();
foreach (var item in ienum) { try { list.Add((int)(dynamic)item); } catch { list.Add(item.GetHashCode()); } }
return (T)(object)list;
}
return (T)val;
}
public static T GetPropertyValue<T>(this object o, string propertyName, bool exceptionIfNotFound = true)
{
var val = o.GetPropertyValue(propertyName, exceptionIfNotFound);
if (val == null) return default;
if (typeof(T) == typeof(List<int>) && val is System.Collections.IEnumerable ienum && !(val is List<int>))
{
var list = new List<int>();
foreach (var item in ienum) { try { list.Add((int)(dynamic)item); } catch { list.Add(item.GetHashCode()); } }
return (T)(object)list;
}
return (T)val;
}
public static T GetMemberValue<T>(this object o, string memberName, bool exceptionIfNotFound = true)
{
var val = o.GetMemberValue(memberName, exceptionIfNotFound);
if (val == null) return default;
if (typeof(T) == typeof(List<int>) && val is System.Collections.IEnumerable ienum && !(val is List<int>))
{
var list = new List<int>();
foreach (var item in ienum) { try { list.Add((int)(dynamic)item); } catch { list.Add(item.GetHashCode()); } }
return (T)(object)list;
}
return (T)val;
}
public static T InvokeMethod<T>(this object o, string methodName, params object[] parameters) => (T)o.InvokeMethod(methodName, parameters);