상속: IRazorConfiguration
예제 #1
0
        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);
        }
예제 #2
0
        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("*")));
        }
예제 #3
0
        public void ConfigIsLoadedFromXml()
        {
            var config = new RazorConfig();

            config.Initializer.InitializeByXmlContent(
                @"
<xipton.razor>
    <rootOperator path=""/foo"" />
</xipton.razor>
"
                );
            Assert.AreEqual(config.RootOperator.Path, "/foo");
        }
예제 #4
0
        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);
        }
예제 #5
0
        /// <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",
            };
        }
예제 #6
0
 public RazorMachine(RazorConfig config)
 {
     Context = new RazorContext(config ?? new RazorConfig().Initializer.TryInitializeFromConfig().AsReadOnly());
 }
예제 #7
0
 /// <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);
 }
예제 #8
0
 /// <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);
 }
예제 #9
0
 public RazorMachine(RazorConfig config)
 {
     Context = new RazorContext(config);
 }