public void Process(AspViewFile file) { Match pageDirective = findPageDirective.Match(file.ViewSource); DetermineScriptingLanguage(file, pageDirective.Groups["language"]); DetermineTypedViewName(file, pageDirective.Groups["view"]); GetPreProcessor(file.Language).Process(file); }
private static void DetermineTypedViewName(AspViewFile file, Group view) { if (view != null) { file.TypedViewName = view.Value; } }
private static void SaveFile(AspViewFile file, string targetDirectory) { string fileName = Path.Combine(targetDirectory, file.FileName); using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8)) { sw.Write(file.ConcreteClass); sw.Flush(); } }
private static void DetermineScriptingLanguage(AspViewFile file, Group languageName) { switch (languageName.Value.ToLower()) { case "c#": file.Language = ScriptingLanguage.CSharp; break; case "vb": file.Language = ScriptingLanguage.VbNet; break; default: throw new AspViewException("Unsupported view language [{0}] in view [{1}]", languageName, file.ViewName); } }
private void DetermineScriptingLanguage(AspViewFile file) { string languageName = findPageDirective.Match(file.ViewSource).Groups["language"].Value.ToLower(); switch (languageName) { case "c#": file.Language = ScriptingLanguage.CSharp; break; case "vb": file.Language = ScriptingLanguage.VbNet; break; default: throw new AspViewException("Unsupported view language [{0}] in view [{1}]", languageName, file.ViewName); } }
private List <AspViewFile> GetViewFiles(string siteRoot) { List <AspViewFile> files = new List <AspViewFile>(); string viewsDirectory = Path.Combine(siteRoot, "Views"); string[] fileNames = Directory.GetFiles(viewsDirectory, "*.aspx", SearchOption.AllDirectories); foreach (string fileName in fileNames) { AspViewFile file = new AspViewFile(); file.ViewName = fileName.Replace(viewsDirectory, ""); file.ClassName = AspViewEngine.GetClassName(file.ViewName); file.ViewSource = ReadFile(fileName); files.Add(file); } return(files); }
/// <summary> /// Transferres an AspView file to a concrete CLI compliant class in C# or VB.NET (VB.NET not implemented yet) /// </summary> /// <param name="file">An AspViewFile to be processed</param> public void Process(AspViewFile file) { int index = 0; sectionHandlers = new Dictionary <string, string>(); Dictionary <string, object> imports = new Dictionary <string, object>(); Dictionary <string, object> references = new Dictionary <string, object>(); Dictionary <string, ViewProperty> properties = new Dictionary <string, ViewProperty>(); string directivesSection = GetDirectivesSection(file.ViewSource, ref index); string propertiesSection = GetPropertiesSection(file.ViewSource, ref index); string viewBody = GetViewBody(file.ViewSource, ref index); ProcessDirectives(directivesSection, imports, references); ProcessProperties(propertiesSection, properties); viewBody = ProcessViewBody(viewBody); StringWriter writer = new StringWriter(); WriteImports(writer, imports); WriteNamespace(writer, assemblyNamespace); WriteOpenTag(writer); WriteClassDecleration(writer, file.ClassName); WriteOpenTag(writer); WriteConstructorDefinition(writer, file.ClassName); WriteProperties(writer, properties); WriteRenderDecleration(writer); WriteOpenTag(writer); WriteRenderBody(writer, viewBody); WriteSubCloseTag(writer); WriteViewNameProperty(writer, file.ViewName); WriteViewDirectoryProperty(writer, GetDirectory(file.ViewName)); WriteSectionHandlers(writer); WriteClassCloseTag(writer); WriteNamespaceCloseTag(writer); file.ConcreteClass = writer.GetStringBuilder().ToString(); }
/// <summary> /// Transferres an AspView file to a concrete CLI compliant class in C# or VB.NET (VB.NET not implemented yet) /// </summary> /// <param name="file">An AspViewFile to be processed</param> public void Process(AspViewFile file) { int index = 0; sectionHandlers = new Dictionary<string, string>(); Dictionary<string, object> imports = new Dictionary<string, object>(); Dictionary<string, object> references = new Dictionary<string, object>(); Dictionary<string, ViewProperty> properties = new Dictionary<string, ViewProperty>(); string directivesSection = GetDirectivesSection(file.ViewSource, ref index); string propertiesSection = GetPropertiesSection(file.ViewSource, ref index); string viewBody = GetViewBody(file.ViewSource, ref index); ProcessDirectives(directivesSection, imports, references); ProcessProperties(propertiesSection, properties); viewBody = ProcessViewBody(viewBody); StringWriter writer = new StringWriter(); WriteImports(writer, imports); WriteNamespace(writer, assemblyNamespace); WriteOpenTag(writer); WriteClassDecleration(writer, file.ClassName, file.TypedViewName); WriteOpenTag(writer); WriteConstructorDefinition(writer, file.ClassName); WriteProperties(writer, properties); WriteRenderDecleration(writer); WriteOpenTag(writer); WriteRenderBody(writer, viewBody); WriteSubCloseTag(writer); WriteViewNameProperty(writer, file.ViewName); WriteViewDirectoryProperty(writer, GetDirectory(file.ViewName)); WriteSectionHandlers(writer); WriteClassCloseTag(writer); WriteNamespaceCloseTag(writer); file.ConcreteClass = writer.GetStringBuilder().ToString(); }
public void Process(AspViewFile file) { DetermineScriptingLanguage(file); GetPreProcessor(file.Language).Process(file); }
private List<AspViewFile> GetViewFiles(string siteRoot) { List<AspViewFile> files = new List<AspViewFile>(); string viewsDirectory = Path.Combine(siteRoot, "Views"); string[] fileNames = Directory.GetFiles(viewsDirectory, "*.aspx", SearchOption.AllDirectories); foreach (string fileName in fileNames) { AspViewFile file = new AspViewFile(); file.ViewName = fileName.Replace(viewsDirectory, ""); file.ClassName = AspViewEngine.GetClassName(file.ViewName); file.ViewSource = ReadFile(fileName); files.Add(file); } return files; }
private static void DetermineTypedViewName(AspViewFile file, Group view) { if (view != null) file.TypedViewName = view.Value; }