public void Check(Configuration configuration, out List<string> errors)
        {
            errors = new List<string>();

            foreach (var configurationItem in configuration.ConfigurationItems)
            {
                foreach (var configurationRule in configurationItem.ConfigurationRules)
                {
                    if (configurationRule is MaxSelectedOptionsRule)
                    {
                        string error;
                        MaxSelectedOptionsRuleCheck(configurationItem, configurationRule as MaxSelectedOptionsRule, out error);
                        if (!string.IsNullOrEmpty(error))
                        {
                            errors.Add(error);
                        }
                    }

                    if (configurationRule is MinSelectedOptionsRule)
                    {
                        string error;
                        MinSelectedOptionsRuleCheck(configurationItem, configurationRule as MinSelectedOptionsRule, out error);
                        if (!string.IsNullOrEmpty(error))
                        {
                            errors.Add(error);
                        }
                    }
                }
            }
        }
        private ExecutedConfiguration Build(Configuration configuration)
        {
            var export = new ExecutedConfiguration
            {
                Name = configuration.Name,
                Description = configuration.Description
            };

            foreach (var item in configuration.ConfigurationItems)
            {
                var eci = new ExecutedConfigurationItem
                {
                    Name = item.Name
                };

                foreach (var configurationItemOption in item.ConfigurationItemOptions)
                {
                    eci.ConfigurationItemOptions.Add(new ExecutedConfigurationItemOption
                    {
                        Name = configurationItemOption.Name,
                        Description = configurationItemOption.Description,
                        IsSelected = configurationItemOption.IsSelected
                    });
                }

                export.ConfigurationItems.Add(eci);
            }

            return export;
        }
        public decimal Calculate(Configuration configuration)
        {
            var price = configuration.Price;

            foreach (var configurationItem in configuration.ConfigurationItems)
            {
                price += configurationItem.Price;

                price += configurationItem.ConfigurationItemOptions
                    .Where(i => i.IsSelected)
                    .Sum(configurationItemOption => configurationItemOption.Price);
            }
            return price;
        }
 public string ExportToJson(Configuration configuration)
 {
     var export = Build(configuration);
     return JsonConvert.SerializeObject(export);
 }