Running the risk of being shouted down for lack of examples but I'm trying to access all of the property names/values from a list of non public members of an object:
Tried this which returns null:
var temp = (cbBasket).GetType().GetProperties().ToDictionary(p => p.Name, p => p.GetValue(cbBasket));
And this which returns the type but not the value plus the list contained over 90 key value pairs so I doubt if this is correct (!)
Type myBasket = cbBasket.GetType();
var myMemberInfo = myBasket.GetMembers();
for (int i = 0; 1 < myMemberInfo.Length; i )
{
var zString = myMemberInfo[i].Name " " myMemberInfo[i].MemberType;
}
Any help would be greatly appreciated. Thanks, C
CodePudding user response:
Looking through the source code, it seems you want something like this:
ChargeBee.Api.Params parameters = cbBasket.Params();
var dict = (Dictionary<string, object>)typeof(ChargeBee.Api.Params)
.GetField("m_dict", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(parameters);