/// <summary> /// Throws exception says that given type was not found in any accessible assembly /// </summary> /// <param name="razorAssemblyProvider">An <see cref="RazorAssemblyProvider"/> instance.</param> /// <param name="type">Type that was not found</param> public static void ThrowTypeNotFound(RazorAssemblyProvider razorAssemblyProvider, string type) { throw new NotSupportedException(string.Format( "Unable to discover CLR Type for model by the name of {0}.\n\nTry using a fully qualified type name and ensure that the assembly is added to the configuration file.\n\nCurrent RazorAssemblyProvider assemblies:\n\t{1}.", type, razorAssemblyProvider.GetAssemblies().Select(a => a.FullName).Aggregate((n1, n2) => n1 + "\n\t" + n2))); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment, IAssemblyCatalog assemblyCatalog) { this.razorAssemblyProvider = new RazorAssemblyProvider(configuration, assemblyCatalog); this.viewRenderer = new CSharpRazorViewRenderer(this.razorAssemblyProvider); this.razorConfiguration = configuration; this.traceConfiguration = environment.GetValue<TraceConfiguration>(); this.AddDefaultNameSpaces(this.viewRenderer.Host); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment, IAssemblyCatalog assemblyCatalog) { this.razorAssemblyProvider = new RazorAssemblyProvider(configuration, assemblyCatalog); this.viewRenderer = new CSharpRazorViewRenderer(this.razorAssemblyProvider); this.razorConfiguration = configuration; this.traceConfiguration = environment.GetValue <TraceConfiguration>(); this.AddDefaultNameSpaces(this.viewRenderer.Host); }
/// <summary> /// Initializes new instance of ClrTypeResolver class. /// Provided parameters are used to recognized specific symbols in particular language /// </summary> /// <param name="razorAssemblyProvider">An <see cref="RazorAssemblyProvider"/> used to resolve model types from the available assemblies.</param> /// <param name="identifier">Symbol type for identifier</param> /// <param name="keyword">Symbol type for keyword</param> /// <param name="dot">Symbol type for dot ('.')</param> /// <param name="whiteSpace">Symbol type for whitespace</param> /// <param name="arrayBegin">Type of symbol that begins array</param> /// <param name="arrayEnd">Type of symbol that ends array</param> protected ClrTypeResolver(RazorAssemblyProvider razorAssemblyProvider, TSymbolType identifier, TSymbolType keyword, TSymbolType dot, TSymbolType whiteSpace, TSymbolType arrayBegin, TSymbolType arrayEnd) { this.razorAssemblyProvider = razorAssemblyProvider; this.identifier = identifier; this.keyword = keyword; this.dot = dot; this.whiteSpace = whiteSpace; this.arrayBegin = arrayBegin; this.arrayEnd = arrayEnd; }
/// <summary> /// Initializes a new instance of the <see cref="NancyRazorEngineHost"/> class. /// </summary> public NancyRazorEngineHost(RazorCodeLanguage language, RazorAssemblyProvider razorAssemblyProvider) : base(language) { this.razorAssemblyProvider = razorAssemblyProvider; this.DefaultBaseClass = typeof (NancyRazorViewBase).FullName; this.DefaultNamespace = "RazorOutput"; this.DefaultClassName = "RazorView"; var context = new GeneratedClassContext("Execute", "Write", "WriteLiteral", "WriteTo", "WriteLiteralTo", typeof (HelperResult).FullName, "DefineSection"); context.ResolveUrlMethodName = "ResolveUrl"; this.GeneratedClassContext = context; }
/// <summary> /// Initializes a new instance of the <see cref="NancyRazorEngineHost"/> class. /// </summary> public NancyRazorEngineHost(RazorCodeLanguage language, RazorAssemblyProvider razorAssemblyProvider) : base(language) { this.razorAssemblyProvider = razorAssemblyProvider; this.DefaultBaseClass = typeof(NancyRazorViewBase).FullName; this.DefaultNamespace = "RazorOutput"; this.DefaultClassName = "RazorView"; var context = new GeneratedClassContext("Execute", "Write", "WriteLiteral", "WriteTo", "WriteLiteralTo", typeof(HelperResult).FullName, "DefineSection"); context.ResolveUrlMethodName = "ResolveUrl"; this.GeneratedClassContext = context; }