protected override Task <int> ExecuteCoreAsync() { if (!Parent.Checker.Check(ExtensionFilePaths.Values)) { Error.WriteLine($"Extensions could not be loaded. See output for details."); return(Task.FromResult(ExitCodeFailure)); } // Loading all of the extensions should succeed as the dependency checker will have already // loaded them. var extensions = new RazorExtension[ExtensionNames.Values.Count]; for (var i = 0; i < ExtensionNames.Values.Count; i++) { extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); } var version = RazorLanguageVersion.Parse(Version.Value()); var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); var sourceItems = GetSourceItems(ProjectDirectory.Value(), Sources.Values, Outputs.Values, RelativePaths.Values, DocumentKinds.Values); var result = ExecuteCore( configuration: configuration, projectDirectory: ProjectDirectory.Value(), tagHelperManifest: TagHelperManifest.Value(), sourceItems: sourceItems); return(Task.FromResult(result)); }
public Task Process(HttpContext context) { dynamic model = new ExpandoObject(); string fileName = GetFileName(); IRazorEngine razorEngine = RazorUtil.ToolkitEngine; string html = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(razorEngine, fileName, null, model, null)).GetAwaiter().GetResult(); return(context.Response.WriteAsync(html)); }
private string RazorOutputFile(object tableData, object model, object pageData, string RazorFile, bool isEdit, int?index = null) { var viewBag = GetNewViewBag(tableData, pageData, CreateCustomData(isEdit), index); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(RazorUtil.MULTIEDIT_ENGINE_NAME); string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, RazorFile, null, model, null, viewBag)).GetAwaiter().GetResult(); return(content); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { object model = WebRazorUtil.GetModel(outputData); var viewBag = WebRazorUtil.GetViewBag(pageData, fMetaData, null, RazorData); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(EngineName); string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(fFileName) : fFileName; string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, fileName, Layout, model, null, viewBag)).GetAwaiter().GetResult(); return(new SimpleContent(ContentTypeConst.HTML, content)); }
private static string Execute(object model, dynamic viewBag, PageTemplateInitData initData, string razorFile, string layout, IPageTemplate pageTemplate, ISource source, IInputData input, OutputData outputData) { string engineName = pageTemplate.GetEngineName(source, input, outputData); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(engineName); string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, razorFile, layout, model, initData, viewBag)).GetAwaiter().GetResult(); return(content); }
public SerializationTest() { var languageVersion = RazorLanguageVersion.Experimental; var extensions = new RazorExtension[] { new SerializedRazorExtension("TestExtension"), }; Configuration = RazorConfiguration.Create(languageVersion, "Custom", extensions); ProjectWorkspaceState = new ProjectWorkspaceState(new[] { TagHelperDescriptorBuilder.Create("Test", "TestAssembly").Build(), }, LanguageVersion.LatestMajor); var converterCollection = new JsonConverterCollection(); converterCollection.RegisterRazorConverters(); Converters = converterCollection.ToArray(); }
protected override Task <int> ExecuteCoreAsync() { // Loading all of the extensions should succeed as the dependency checker will have already // loaded them. var extensions = new RazorExtension[ExtensionNames.Values.Count]; for (var i = 0; i < ExtensionNames.Values.Count; i++) { extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); } var version = RazorLanguageVersion.Parse(Version.Value()); var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); var result = ExecuteCore( configuration: configuration, projectDirectory: ProjectDirectory.Value(), outputFilePath: TagHelperManifest.Value(), assemblies: Assemblies.Values.ToArray()); return(Task.FromResult(result)); }
/// <summary>Gets the strongly-typed property accessor used to get value from the current project snapshot Extension Properties properties.</summary> internal bool TryGetCurrentRazorExtensionPropertiesSnapshot(out RazorExtension snapshot, [System.Runtime.InteropServices.OptionalAttribute()][System.Runtime.InteropServices.DefaultParameterValueAttribute(true)] bool requiredToMatchProjectVersion) { snapshot = null; Microsoft.VisualStudio.ProjectSystem.IProjectVersionedValue <Microsoft.VisualStudio.ProjectSystem.Properties.IProjectCatalogSnapshot> catalogSnapshot; if (this.TryGetCurrentCatalogSnapshot(out catalogSnapshot)) { if (requiredToMatchProjectVersion) { if ((this.ConfiguredProject.ProjectVersion.CompareTo(catalogSnapshot.DataSourceVersions[Microsoft.VisualStudio.ProjectSystem.ProjectDataSources.ConfiguredProjectVersion]) != 0)) { return(false); } } Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule = this.GetSnapshotRule(catalogSnapshot.Value, "Project", RazorExtension.SchemaName); if ((rule != null)) { snapshot = new RazorExtension(rule, this.ConfiguredProject); return(true); } } return(false); }