public BoolNames Merge(BoolNames sec)
 {
     if (TrueName.IsNulle())
     {
         TrueName = sec?.TrueName;
     }
     if (FalseName.IsNulle())
     {
         FalseName = sec?.FalseName;
     }
     if (NotSetName.IsNulle())
     {
         NotSetName = sec?.NotSetName;
     }
     return(this);
 }
        public (string optionLabel, InputColItem[]) GetInputCollectionItems(
            bool winnowNullSelectOption,
            string optionLabel  = null,
            BoolNames boolNames = null,
            IEnumerable <InputColItem> items       = null,
            IEnumerable <string> enumNames         = null,
            object selectedValueForModelCollection = null)
        {
            InputModelInfo modelInfo = this;

            if (items != null)
            {
                InputColItem[] _items = items.ToArray();
                if (_items.NotNulle())
                {
                    if (!_items.Any(kv => kv.IsSelected))
                    {
                        throw new NotImplementedException();
                        // RUN to find first selected, if any...
                    }
                    return(optionLabel, _items);
                }
            }

            Type mainTyp        = modelInfo.MainType;
            bool typeIsNullable = modelInfo.ModelTypeIsNullable;

            bool isBool = mainTyp.IsPrimitive && mainTyp == typeof(bool);
            bool isEnum = !isBool && mainTyp.IsEnum;

            if (isBool)
            {
                bool?modelValBool = (bool?)ModelValue;

                BoolNames bn = boolNames ?? DefaultBoolNames;
                if (boolNames != null)
                {
                    bn.HtmlEncodeValues().Merge(DefaultBoolNames);
                }

                var nameValues = new InputColItem[] {
                    new InputColItem(bn.TrueName, true, modelValBool == true),
                    new InputColItem(bn.FalseName, false, modelValBool == false),
                    modelInfo.ModelTypeIsNullable
                                                ? new InputColItem(bn.NotSetName, null, modelValBool == null)
                                                : null,
                };
                var _items = _alterCollForSelectOption(nameValues, winnowNullSelectOption, ref optionLabel);
                return(optionLabel, _items);                  // see note below, can't call with ref setter in return line
            }
            else if (isEnum)
            {
                InputColItem[] _items = GetInputEnumValues(enumNames, values: null, countNullAsIsChecked: true);
                _items = _alterCollForSelectOption(_items, winnowNullSelectOption, ref optionLabel);
                // interesting! - the ref set won't set if called within the return line! so must put this line above
                return(optionLabel, _items);
            }
            else
            {
                object modelValue = modelInfo.ModelValue;
                if (modelValue != null)
                {
                    if (modelValue is IEnumerable <object> arr)
                    {
                        List <InputColItem> kvlist = new List <InputColItem>();

                        bool _allowStringEquality = selectedValueForModelCollection != null &&
                                                    AllowStringBasedEqualityComparison(selectedValueForModelCollection.GetType());

                        foreach (object value in arr)
                        {
                            if (value != null)
                            {
                                string valueName = value.ToString();
                                if (valueName.NotNulle())
                                {
                                    bool isSel = selectedValueForModelCollection == null
                                                                                ? false
                                                                                : ObjectIsEqual(selectedValueForModelCollection, valueName, value, countNullAsIsCheckedMatch: true, allowStringEquality: _allowStringEquality);

                                    var _item = new InputColItem(valueName, value, isSel);
                                    kvlist.Add(_item);
                                }
                            }
                        }
                        return(optionLabel, kvlist.Where(kv => kv != null).ToArray());
                    }
                }
            }
            return(optionLabel, null);
        }