ACR_BuilderPlugin.ToolsetHelper.GetControlOfFieldType C# (CSharp) Method

GetControlOfFieldType() public static method

public static GetControlOfFieldType ( Type type ) : UserControl
type System.Type
return System.Windows.Forms.UserControl
        public static UserControl GetControlOfFieldType(Type type)
        {
            FieldInfo[] fields = NWN2Toolset.NWN2ToolsetMainForm.App.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            foreach (FieldInfo field in fields)
            {
                if (field.FieldType == type)
                    return (UserControl)field.GetValue(NWN2Toolset.NWN2ToolsetMainForm.App);
            }
            throw new Exception(String.Format("Could not find UserControl of type {0}.", type.ToString()));
        }