示例#1
0
        private static IEnumerable <string> GetComponentScripts(string component)
        {
            var allScripts = new List <string>();

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

                if (componentDefinitionObject.Scripts != null)
                {
                    allScripts.AddRange(componentDefinitionObject.Scripts);
                }

                if (componentDefinitionObject.Components != null)
                {
                    foreach (var comp in componentDefinitionObject.Components)
                    {
                        allScripts.AddRange(ScriptDependencyResolver.GetComponentScripts(comp));
                    }
                }
            }
            else
            {
                Log.Write(string.Format(System.Globalization.CultureInfo.InvariantCulture, "The component {0} could not be resolved", component));
            }

            return(allScripts.Distinct());
        }
示例#2
0
        /// <summary>
        /// Gets the scripts.
        /// </summary>
        /// <param name="components">The components.</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(ScriptDependencyResolver.GetComponentScripts(comp));
            }

            return(ScriptDependencyResolver.OrderScripts(dependencyScripts, originalScripts));
        }