public IEnumerable <OptimizationPassBase> Closure(IEnumerable <string> capabilies)
        {
            var result      = new HashSet <string>();
            var resultItems = new List <OptimizationPassBase>();


            var fullCapabilities = BuildFullCapabilities(capabilies);

            foreach (var capability in fullCapabilities)
            {
                Type optimizationType;
                if (!OptimizationTypes.TryGetValue(capability, out optimizationType))
                {
                    continue;
                }
                if (!result.Add(capability))
                {
                    continue;
                }
                var activated = (OptimizationPassBase)Activator.CreateInstance(optimizationType);
                resultItems.Add(activated);
            }

            return(resultItems);
        }
        public void BuildRelationsByReflection()
        {
            var assembly = GetType().Assembly;

            OptimizationTypes.Clear();
            foreach (var type in assembly.GetTypes())
            {
                if (!type.IsSubclassOf(typeof(OptimizationPassBase)))
                {
                    continue;
                }
                var optimizationAttribute = type.GetCustomAttribute <OptimizationAttribute>();
                if (optimizationAttribute == null)
                {
                    continue;
                }
                AddChildToParentOptimizationRelation(optimizationAttribute.Category, type.Name);
                OptimizationTypes[type.Name] = type;
            }
        }