private void writeCustomControls(GH_IWriter writer, IEnumerable <GHControl> customControls, string path)
        {
            foreach (GHControl control in customControls)
            {
                string name = (path.Length > 0) ? (path + "." + control.Name): control.Name;
                if (control is GHParameter)
                {
                    GHParameter param = (GHParameter)control;
                    switch (param.DataType)
                    {
                    case GH_Types.gh_bool:
                        writer.SetBoolean(name, (bool)param.CurrentValue);
                        break;

                    case GH_Types.gh_double:
                        writer.SetDouble(name, (double)param.CurrentValue);
                        break;

                    case GH_Types.gh_int32:
                        writer.SetInt32(name, (int)param.CurrentValue);
                        break;

                    case GH_Types.gh_decimal:
                        writer.SetDecimal(name, Convert.ToDecimal(param.CurrentValue));
                        break;
                    }
                }
                if (control is IGHPanel)
                {
                    writeCustomControls(writer, ((IGHPanel)control).Items, name);
                }
            }
        }