private bool ContainsValidAutoSubcomponentFor(ComponentAutoFunction _fct)
        {
            List <Parameter.Parameter> parameters_for_check = new List <Parameter.Parameter>();

            switch (_fct)
            {
            case ComponentAutoFunction.CUMULATION:
                parameters_for_check = Parameter.Parameter.GetCumulativeParametersForInstancing();
                break;

            default:
                parameters_for_check = Parameter.Parameter.GetSizeParametersForInstancing();
                break;
            }

            foreach (var entry in this.ContainedComponents)
            {
                Component c = entry.Value;
                if (c == null)
                {
                    continue;
                }

                if (!c.IsAutomaticallyGenerated)
                {
                    continue;
                }
                // if (c.R2GMainState.Type != Relation2GeomType.CONTAINED_IN && c.R2GMainState.Type != Relation2GeomType.CONNECTS) continue;

                // check the specific parameters
                bool contains_all_p      = false;
                bool missed_at_least_one = true;
                foreach (Parameter.Parameter p in parameters_for_check)
                {
                    missed_at_least_one = false;
                    Parameter.Parameter corresponding = c.ContainedParameters.FirstOrDefault(x => x.Value.Name == p.Name && x.Value.Unit == p.Unit && x.Value.Propagation == p.Propagation).Value;
                    if (corresponding == null)
                    {
                        missed_at_least_one = true;
                        break;
                    }
                }
                contains_all_p = !missed_at_least_one;
                if (contains_all_p)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void AutoAddSubcomponent(string _name, string _description, ComponentAutoFunction _fct)
        {
            if (this.Factory == null)
            {
                return;
            }

            Component created = new Component();

            created.Factory     = this.Factory;
            created.Name        = _name;
            created.Description = _description;
            created.SetupForAutomaticallyCreatedComps(this.GetManagerWWritingAccess());

            // get the correct parameter set
            switch (_fct)
            {
            case ComponentAutoFunction.CUMULATION:
                created.AddCumulativeParamsForNWCalculations();
                break;

            default:
                created.AddSizeParamsForNWCalculations();
                break;
            }

            // add to the parent
            string slot     = this.GenerateSlotFor(Relation2GeomType.CONTAINED_IN, true);
            bool   success0 = this.AddSubComponentSlot(slot, ComponentManagerType.ADMINISTRATOR);

            if (success0)
            {
                bool success1 = this.AddSubComponent(slot, created, ComponentManagerType.ADMINISTRATOR);
                if (success1)
                {
                    // update the internal factory containers
                    this.Factory.UpdateFlatComponentList();
                }
            }
        }