public void ConfigCanBeCreated() { var config = new RazorConfig(); Assert.IsNotNull(config.ContentProviders); Assert.IsNotNull(config.Namespaces); Assert.IsNotNull(config.References); Assert.IsNotNull(config.RootOperator); Assert.IsNotNull(config.Templates); }
public void ConfigCanBeCreatedWithoutWildcards() { var config = new RazorConfig(false); Assert.IsNotNull(config.ContentProviders); Assert.IsNotNull(config.Namespaces); Assert.IsNotNull(config.References); Assert.IsNotNull(config.RootOperator); Assert.IsNotNull(config.Templates); Assert.IsFalse(config.References.Any(r => r.Contains("*"))); }
public void ConfigIsLoadedFromXml() { var config = new RazorConfig(); config.Initializer.InitializeByXmlContent( @" <xipton.razor> <rootOperator path=""/foo"" /> </xipton.razor> " ); Assert.AreEqual(config.RootOperator.Path, "/foo"); }
public string RenderPage(RazorConfig config) { StringWriter writer; transformer.SetControllerContext(config.controllerContext); transformer.LoadTemplate(config.viewPath); transformer.AttachModel(config.viewModel); transformer.TransformTemplate(out writer); var html = transformer.DecodeToString(writer); return(html); }
/// <summary> /// Initializes a new instance of the <see cref="XiptonEngineHost"/> class. /// </summary> /// <param name="config">The config holds all settings that are needed to initialzie the host.</param> public XiptonEngineHost(RazorConfig config) : base(config.Templates.Language) { if (config == null) { throw new ArgumentNullException("config"); } _defaultNamespace = "Xipton.Razor.Generated"; _config = config.AsReadonly(); _defaultBaseClass = _config.Templates.NonGenericBaseTypeName; _namespaceImports = new HashSet <string>(); _config.Namespaces.ToList().ForEach(ns => _namespaceImports.Add(ns)); // the GeneratedClassContext defines the methods that are generated to handle the template // control like writing the generated output and also handle other control operations like // defining sections inside the template _generatedClassContext = new GeneratedClassContext("Execute", "Write", "WriteLiteral", "WriteTo", "WriteLiteralTo", typeof(HelperResult).FullName, "DefineSection") { ResolveUrlMethodName = "ResolveUrl", }; }
public RazorMachine(RazorConfig config) { Context = new RazorContext(config ?? new RazorConfig().Initializer.TryInitializeFromConfig().AsReadOnly()); }
/// <summary> /// Initializes a new instance of the <see cref="RazorContext"/> class. /// </summary> public RazorContext(RazorConfig config = null) { Config = config ?? new RazorConfig(); TemplateFactory = new TemplateFactory(this); }
/// <summary> /// Initializes a new instance of the <see cref="RazorContext"/> class. /// </summary> public RazorContext(RazorConfig config = null) { Config = (config ?? new RazorConfig().Initializer.TryInitializeFromConfig().CastTo <RazorConfig>()).AsReadonly(); TemplateFactory = new TemplateFactory(this); }
public RazorMachine(RazorConfig config) { Context = new RazorContext(config); }