/// <summary>
        /// Gets the scripts.
        /// </summary>
        /// <param name="components">The components.</param>
        /// <param name="scripts">The scripts.</param>
        /// <returns></returns>
        public static IList <string> GetScripts(IEnumerable <string> components, IEnumerable <string> scripts)
        {
            if (components == null)
            {
                components = new List <string>();
            }

            if (scripts == null)
            {
                scripts = new List <string>();
            }

            var originalScripts = scripts.ToList();

            if (!components.Any())
            {
                return(originalScripts);
            }

            var dependencyScripts = new List <string>();

            foreach (var comp in components)
            {
                dependencyScripts.AddRange(ComponentsDependencyResolver.GetComponentDependencies(comp, DependencyType.Scripts));
            }

            return(ComponentsDependencyResolver.OrderScripts(dependencyScripts, originalScripts));
        }
        /// <summary>
        /// Gets the modules where components are defined.
        /// </summary>
        /// <param name="components">The components.</param>
        /// <returns></returns>
        public static IList <string> GetModules(IEnumerable <string> components)
        {
            if (components == null)
            {
                components = new List <string>();
            }

            var modules = new List <string>();

            foreach (var comp in components)
            {
                modules.AddRange(ComponentsDependencyResolver.GetComponentDependencies(comp, DependencyType.Modules));
            }

            return(modules);
        }
        private static IEnumerable <string> GetComponentDependencies(string component, DependencyType dependencyType)
        {
            var allDependencies = new List <string>();

            if (!string.IsNullOrEmpty(component) && ComponentsDependencyResolver.ComponentsDefinitionsDictionary.Value.ContainsKey(component))
            {
                var componentDefinitionObject = ComponentsDependencyResolver.ComponentsDefinitionsDictionary.Value[component];

                if (dependencyType == DependencyType.Scripts)
                {
                    if (componentDefinitionObject.Scripts != null)
                    {
                        allDependencies.AddRange(componentDefinitionObject.Scripts);
                    }
                }
                else
                {
                    if (componentDefinitionObject.AngularModules != null)
                    {
                        allDependencies.AddRange(componentDefinitionObject.AngularModules);
                    }
                }

                if (componentDefinitionObject.Components != null && dependencyType == DependencyType.Scripts)
                {
                    foreach (var comp in componentDefinitionObject.Components)
                    {
                        allDependencies.AddRange(ComponentsDependencyResolver.GetComponentDependencies(comp, dependencyType));
                    }
                }
            }
            else
            {
                Log.Write(string.Format(System.Globalization.CultureInfo.InvariantCulture, "The component {0} could not be resolved", component));
            }

            return(allDependencies.Distinct());
        }