Example #1
0
        PartModule find_module(ConfigureModule cm)
        {
            // for each module in the part
            foreach (PartModule m in part.Modules)
            {
                // if the module type match
                if (m.moduleName == cm.type)
                {
                    // if the module field is not necessary
                    if (cm.id_field.Length == 0)
                    {
                        // found it
                        return(m);
                    }
                    // if the module field match
                    else
                    {
                        // get identifier
                        string id = Lib.ReflectionValue <string>(m, cm.id_field);

                        // if the identifier match
                        if (id == cm.id_value)
                        {
                            // found it
                            return(m);
                        }
                    }
                }
            }

            // not found
            return(null);
        }
Example #2
0
        public PartModule find_module(ConfigureModule cm)
        {
            // for each module in the part
            int index = 0;

            foreach (PartModule m in part.Modules)
            {
                // if the module type match
                if (m.moduleName == cm.type)
                {
                    // if the module field is not specified
                    if (cm.id_field.Length == 0)
                    {
                        // search it by index
                        if (index == cm.id_index)
                        {
                            return(m);
                        }
                    }
                    // if the module field match
                    else
                    {
                        // get identifier
                        string id = Lib.ReflectionValue <string>(m, cm.id_field);

                        // if the identifier match
                        if (id == cm.id_value)
                        {
                            // found it
                            return(m);
                        }
                    }
                    ++index;
                }
            }

            // not found
            return(null);
        }