protected void startTrees(HashSet<ScriptResource> pageScripts)
		{
			foreach (var script in pageScripts)
			{
				string name = ScriptResourceKey(script);

				// Support for pagescript dependencies!
				if (!ScriptsBag.ContainsKey(name))
					ScriptsBag.Add(name, script);
				else if (script.Dependencies.Count > 0)
					// PageScript was declared with dependencies - override the AppScripts version
					ScriptsBag[name] = script;

				var tree = new ScriptTree();
				var layer0 = tree.AddLayer(0);
				tree.AddScriptToLayer(0, name, ScriptsBag, SharedDependencies);
				Trees.Add(tree);
			}
		}
		public TreeSharedDependency(string name, ScriptTree firstTree)
		{
			Name = name;
			Trees.Add(firstTree);
		}
Ejemplo n.º 3
0
		public ScriptTreeLayer(ScriptTree tree, int layerNumber)
		{
			Tree = tree;
			LayerNumber = layerNumber;
		}
		protected bool scriptOrdersMatch(IEnumerable<string> scripts, ScriptTree tree1, ScriptTree tree2)
		{
			var tree1Order = getScriptsOrderForTree(scripts, tree1);

			int lastLevel = -1;
			foreach (var hashSet in tree1Order)
			{
				int currentLevel = -1;
				foreach (string script in hashSet)
				{
					if (currentLevel == -1)
					{
						currentLevel = tree2.ScriptLayerMap[script];
						if (currentLevel <= lastLevel)
							return false;

						lastLevel = currentLevel;
					}
					else
					{
						if (tree2.ScriptLayerMap[script] != currentLevel)
							return false;
					}
				}
			}

			return true;
		}
		protected List<HashSet<string>> getScriptsOrderForTree(IEnumerable<string> scripts, ScriptTree tree)
		{
			string[] scriptsInOrder = getScriptsFlatOrderForTree(scripts, tree);

			var list = new List<HashSet<string>>();
			HashSet<string> current = null;

			string lastScript = null;
			foreach (string script in scriptsInOrder)
			{
				if (lastScript != null && tree.ScriptLayerMap[lastScript] == tree.ScriptLayerMap[script])
				{
					current.Add(script);
				}
				else
				{
					current = new HashSet<string>();
					list.Add(current);
					current.Add(script);
				}
				lastScript = script;
			}

			return list;
		}
		protected string[] getScriptsFlatOrderForTree(IEnumerable<string> scripts, ScriptTree tree)
		{
			return scripts.OrderBy(s => tree.ScriptLayerMap[s]).ToArray();
		}