<commit_before>using System.Collections.Generic;
using System.IO;
using MvcContrib.SparkViewEngine;
using MvcContrib.SparkViewEngine.Compiler;
using MvcContrib.SparkViewEngine.Compiler.NodeVisitors;
using MvcContrib.SparkViewEngine.Parser;
using Spark;
using Spark.FileSystem;

namespace Spark
{
	public class SparkViewEngine : ISparkViewEngine
	{
		//public SparkViewEngine()
		//    : this(new FileSystemViewSourceLoader(), new ParserFactory())
		//{

		//}

		public SparkViewEngine(string baseClass, IViewFolder viewFolder)
		{
			BaseClass = baseClass;
			ViewFolder = viewFolder;
		}

		public string BaseClass { get; set; }
		public IViewFolder ViewFolder { get; set; }


		public ISparkViewEntry GetEntry(string controllerName, string viewName, string masterName)
		{
			var key = CreateKey(controllerName, viewName, masterName);
			return CompiledViewHolder.Current.Lookup(key);
		}

		public ISparkView CreateInstance(string controllerName, string viewName, string masterName)
		{
			var key = CreateKey(controllerName, viewName, masterName);
			var entry = CompiledViewHolder.Current.Lookup(key);
			if (entry == null)
			{
				entry = CreateEntry(key);
				CompiledViewHolder.Current.Store(entry);
			}

			return entry.Compiler.CreateInstance();
		}

		//public void RenderView(ViewContext viewContext)
		//{
		//    var key = CreateKey(viewContext);

		//    var entry = CompiledViewHolder.Current.Lookup(key);
		//    if (entry == null)
		//    {
		//        entry = CreateEntry(key);
		//        CompiledViewHolder.Current.Store(entry);
		//    }

		//    var view = entry.Compiler.CreateInstance();
		//    var content = view.RenderView(viewContext);

		//    viewContext.HttpContext.Response.Write(content);
		//}

		//public CompiledViewHolder.Key CreateKey(ViewContext viewContext)
		//{
		//    return CreateKey(
		//        viewContext.RouteData.GetRequiredString("controller"),
		//        viewContext.ViewName,
		//        viewContext.MasterName);
		//}

		public CompiledViewHolder.Key CreateKey(string controllerName, string viewName, string masterName)
		{
			var key = new CompiledViewHolder.Key
			          	{
			          		ControllerName = controllerName ?? string.Empty,
			          		ViewName = viewName ?? string.Empty,
			          		MasterName = masterName ?? string.Empty
			          	};

			if (key.MasterName == string.Empty)
			{
				if (ViewFolder.HasView(string.Format("Shared\\{0}.xml", key.ControllerName)))
				{<commit_msg>Removing commented code<commit_after>using System.Collections.Generic;
using System.IO;
using MvcContrib.SparkViewEngine;
using MvcContrib.SparkViewEngine.Compiler;
using MvcContrib.SparkViewEngine.Compiler.NodeVisitors;
using MvcContrib.SparkViewEngine.Parser;
using Spark;
using Spark.FileSystem;

namespace Spark
{
	public class SparkViewEngine : ISparkViewEngine
	{
		public SparkViewEngine(string baseClass, IViewFolder viewFolder)
		{
			BaseClass = baseClass;
			ViewFolder = viewFolder;
		}

		public string BaseClass { get; set; }
		public IViewFolder ViewFolder { get; set; }


		public ISparkViewEntry GetEntry(string controllerName, string viewName, string masterName)
		{
			var key = CreateKey(controllerName, viewName, masterName);
			return CompiledViewHolder.Current.Lookup(key);
		}

		public ISparkView CreateInstance(string controllerName, string viewName, string masterName)
		{
			var key = CreateKey(controllerName, viewName, masterName);
			var entry = CompiledViewHolder.Current.Lookup(key);
			if (entry == null)
			{
				entry = CreateEntry(key);
				CompiledViewHolder.Current.Store(entry);
			}

			return entry.Compiler.CreateInstance();
		}
	

		public CompiledViewHolder.Key CreateKey(string controllerName, string viewName, string masterName)
		{
			var key = new CompiledViewHolder.Key
			          	{
			          		ControllerName = controllerName ?? string.Empty,
			          		ViewName = viewName ?? string.Empty,
			          		MasterName = masterName ?? string.Empty
			          	};

			if (key.MasterName == string.Empty)
			{
				if (ViewFolder.HasView(string.Format("Shared\\{0}.xml", key.ControllerName)))
				{
{'fraction_non_alphanumeric': 0.10174418604651163, 'fraction_numerical': 0.00048449612403100775, 'mean_word_length': 3.430257510729614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4305328', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1203, 'n_words': 254}