private void UpdateGuiForType(HraObject hraObject) { var hraObjectGetters = hraObject.GetType() .GetMembers(BindingFlags.NonPublic | BindingFlags.Instance); foreach (var property in hraObjectGetters) { // ReSharper disable StringLastIndexOfIsCultureSpecific.1 - Not Applicable int indexOfLastunderscore = property.Name.LastIndexOf("_"); // ReSharper restore StringLastIndexOfIsCultureSpecific.1 string propertyNameWithoutGetPrefix = property.Name.Remove(0, indexOfLastunderscore + 1); Control controlToUpdate = this.groupBox.Controls.Cast <Control>() .SingleOrDefault(control => String.Equals(control.Name, propertyNameWithoutGetPrefix, StringComparison.CurrentCultureIgnoreCase)); if (controlToUpdate != null) { var memberWithName = hraObject.GetMemberByName(propertyNameWithoutGetPrefix); FieldInfo propertyInfo = memberWithName as FieldInfo; if (propertyInfo != null) { object hraObjectValue = propertyInfo.GetValue(hraObject); if (hraObjectValue != null) { controlToUpdate.Text = hraObjectValue.ToString(); } } } } ToggleWidgetsOnOff(); ToggleDateFields(); }