Ejemplo n.º 1
0
        public void Enabled(Feature feature)
        {
            var keyFeaturesToEnable = new List <string>();

            // we check in the lists of dependencies for those KeyFeatures that are not currently enabled
            foreach (var keyFeatureDescriptor in _keyFeaturesProviders.SelectMany(kfp => kfp
                                                                                  .DisabledKeyFeatures(feature)))
            {
                // the feature we just enabled is a dependency of the keyFeature represented by the
                // keyFeatureDescriptor. If all other dependencies are enabled already, we enable the
                // keyFeature too. In other words, if any of the dependencies is disabled we should do
                // nothing.
                if (_featureManager
                    .GetDisabledFeatures() // this is an IEnumerable<FeatureDescriptor>
                    .Any(dfd => keyFeatureDescriptor
                         .Dependencies     // this is an IEnumerable<string> of the dependecies' names
                         .Contains(dfd.Id)))
                {
                    continue; // go to the next keyFeatureDescriptor
                }
                // All dependencies are now enabled, so we enable the KeyFeature too
                keyFeaturesToEnable.Add(keyFeatureDescriptor.Id);
            }

            // Actually enable the KeyFeatures
            _featureManager.EnableFeatures(keyFeaturesToEnable);
        }
Ejemplo n.º 2
0
        public override void Build(BuildContext context)
        {
            if (!ExportEnabledFeatures && !ExportDisabledFeatures)
            {
                return;
            }

            var enabledFeatures  = _featureManager.GetEnabledFeatures();
            var disabledFeatures = _featureManager.GetDisabledFeatures();
            var tomeltElement    = context.RecipeDocument.Element("Tomelt");
            var root             = new XElement("Feature");

            if (ExportEnabledFeatures)
            {
                root.Add(new XAttribute("enable", String.Join(", ", enabledFeatures.Select(x => x.Id).OrderBy(x => x))));
            }

            if (ExportDisabledFeatures)
            {
                root.Add(new XAttribute("disable", String.Join(", ", disabledFeatures.Select(x => x.Id).OrderBy(x => x))));
            }

            tomeltElement.Add(root);
        }
Ejemplo n.º 3
0
 public virtual IEnumerable <FeatureDescriptor> DisabledKeyFeatures()
 {
     return(_featureManager
            .GetDisabledFeatures()
            .Where(fd => KeyFeatureNames.Contains(fd.Id)));
 }