JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
Bannerlord Wiki
Bannerlord Wiki
Type
Global Tables
Campaign
More
Share
Explore
C#
Get Private Fields
private FieldInfo GetPrivateField(object target, string fieldname)
{
Type type = target.GetType();
while (type != null)
{
FieldInfo field = type.GetField(fieldname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
type = type.BaseType;
}
throw new Exception("Error 50");
}
FieldInfo privateField = this.GetPrivateField(missionScreen, "_missionState");
MissionState missionState = (MissionState)privateField.GetValue(missionScreen);
missionState.Paused = this.isPaused;
private FieldInfo GetPrivateField(object target, string fieldname)
{
Type type = target.GetType();
while (type != null)
{
FieldInfo field = type.GetField(fieldname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
type = type.BaseType;
}
throw new Exception("Error 50");
}
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.