public static dynamic Access(dynamic _Value, dynamic _Key)
{
try
{
if (_Value == null) return null;
String Key = (String)_Key;
Object Value = (Object)_Value;
Type ValueType = Value.GetType();
var MethodKey = ValueType.GetMethod(Key);
if (MethodKey != null)
{
return MethodKey.Invoke(Value, new object[] { });
}
var FieldKey = ValueType.GetField(Key);
if (FieldKey != null)
{
return FieldKey.GetValue(Value);
}
var PropertyKey = ValueType.GetProperty(Key);
if (PropertyKey != null)
{
return PropertyKey.GetValue(Value, new object[] { });
}
}
catch (Exception)
{
}
try
{
return _Value[_Key];
}
//catch (Exception Exception)
catch (Exception)
{
//Console.WriteLine(Exception);
return null;
}
}