System.Globalization.FormLanguageSwitchSingleton.SetProperty C# (CSharp) Method

SetProperty() private method

Reloads resources for a property.
private SetProperty ( System control, string propertyName, System resources ) : void
control System /// Control object for which resources should be reloaded. ///
propertyName string /// Name of the property to reload. ///
resources System /// ResourceManager object. ///
return void
		private void SetProperty(System.Windows.Forms.Control control, string propertyName, System.Resources.ResourceManager resources) {
			try {
				PropertyInfo propertyInfo = control.GetType().GetProperty(propertyName);
				if (propertyInfo != null) {
					string controlName = control.Name;
					if (control is System.Windows.Forms.Form)
						controlName = "$this";
					object resObject = resources.GetObject(controlName + "." + propertyName, m_cultureInfo);
					if (resObject != null)
						propertyInfo.SetValue(control, Convert.ChangeType(resObject, propertyInfo.PropertyType), null);
				}
			}
			catch (AmbiguousMatchException e) {
				Trace.WriteLine(e.ToString());
			}
		}