Ejemplo n.º 1
0
 // Loop through all possible variants and generate selection data
 private void GenerateVariantSelections(List <OptionSelectionList> data,
                                        List <Option> options,
                                        int optionIndex,
                                        OptionSelectionList tempSelections)
 {
     if (optionIndex > (options.Count - 1))
     {
         // we've hit all options so add the selections to the data
         OptionSelectionList temp = new OptionSelectionList();
         temp.AddRange(tempSelections);
         //tempSelections.RemoveAt(tempSelections.Count() - 1);
         //tempSelections.Clear();
         data.Add(temp);
     }
     else
     {
         Option opt = options[optionIndex];
         foreach (OptionItem oi in opt.Items)
         {
             if (oi.IsLabel == false)
             {
                 OptionSelectionList localList = new OptionSelectionList();
                 localList.AddRange(tempSelections);
                 localList.Add(new OptionSelection(opt.Bvin, oi.Bvin));
                 GenerateVariantSelections(data, options, optionIndex + 1, localList);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public Variant FindBySelectionData(OptionSelectionList selections, OptionList options)
        {
            OptionSelectionList variantSelections = new OptionSelectionList();

            foreach (Option opt in options)
            {
                if (opt.IsVariant)
                {
                    OptionSelection sel = selections.FindByOptionId(opt.Bvin);
                    if (sel != null)
                    {
                        variantSelections.Add(sel);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            string selectionKey = OptionSelection.GenerateUniqueKeyForSelections(variantSelections);

            return(this.FindByKey(selectionKey));
        }