public static ResolvedTreeRoot ParseResolvedTree(string markup, string fileName = "default.dothtml", DotvvmConfiguration configuration = null, bool checkErrors = true) { configuration = configuration ?? DefaultConfig; var tokenizer = new DothtmlTokenizer(); tokenizer.Tokenize(markup); var parser = new DothtmlParser(); var tree = parser.Parse(tokenizer.Tokens); if (checkErrors) { CheckForErrors(tree); } var controlTreeResolver = configuration.ServiceProvider.GetRequiredService <IControlTreeResolver>(); var validator = ActivatorUtilities.CreateInstance <ControlUsageValidationVisitor>(configuration.ServiceProvider); return(controlTreeResolver.ResolveTree(tree, fileName) .CastTo <ResolvedTreeRoot>() .ApplyAction(new DataContextPropertyAssigningVisitor().VisitView) .ApplyAction(x => { if (checkErrors) { CheckForErrors(x.DothtmlNode); } }) .ApplyAction(new StylingVisitor(configuration).VisitView) .ApplyAction(x => { if (checkErrors) { validator.VisitAndAssert(x); } else { validator.VisitView(x); } })); }
/// <summary> /// Initializes a new instance of the <see cref="DotvvmRouteTable"/> class. /// </summary> public DotvvmRouteTable(DotvvmConfiguration configuration) { this.configuration = configuration; }
private void ConfigureResources(DotvvmConfiguration config, string applicationPath) { // register custom resources and adjust paths to the built-in resources }
public StyleRepository(DotvvmConfiguration configuration) { this.configuration = configuration; }
private void ConfigureResources(DotvvmConfiguration config, string applicationPath) { // register custom resources and adjust paths to the built-in resources config.Resources.Register("site", new StylesheetResource(new FileResourceLocation("~/Style/css/all.css"))); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultViewModelSerializer"/> class. /// </summary> public DefaultViewModelSerializer(DotvvmConfiguration configuration) { this.viewModelProtector = configuration.ServiceLocator.GetService <IViewModelProtector>(); this.JsonFormatting = configuration.Debug ? Formatting.Indented : Formatting.None; this.viewModelMapper = configuration.ServiceLocator.GetService <IViewModelSerializationMapper>(); }
private void ConfigureControls(DotvvmConfiguration config, string applicationPath) { // register code-only controls and markup controls config.Markup.AddMarkupControl("cc", "Sample", "Home/Controls/Sample.dotcontrol"); }
public DiagnosticsDataStore(IViewModelServerStore store, ServerSideCacheDiagnosticsOptions options, DotvvmConfiguration dotvvmConfiguration) { this.store = store; this.options = options; this.dotvvmConfiguration = dotvvmConfiguration; }
public DotvvmFileUploadMiddleware(OwinMiddleware next, DotvvmConfiguration configuration) : base(next) { this.configuration = configuration; }
public void Configure(DotvvmConfiguration config, string applicationPath) { config.AddBootstrap4Configuration(); config.RouteTable.AutoDiscoverRoutes(new WebRouteStrategy(config)); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultControlTreeResolver"/> class. /// </summary> public DefaultControlTreeResolver(DotvvmConfiguration configuration) : base(configuration.ServiceLocator.GetService <IControlResolver>(), configuration.ServiceLocator.GetService <IAbstractTreeBuilder>()) { this.bindingExpressionBuilder = configuration.ServiceLocator.GetService <IBindingExpressionBuilder>(); }
/// <summary> /// Initializes a new instance of the <see cref="ResourceManager"/> class. /// </summary> public ResourceManager(DotvvmConfiguration configuration) { this.configuration = configuration; }
public TextFileDiagnosticsInformationSender(DotvvmConfiguration config) { this.config = config; logFilePath = GetFilePath(); }
public static DotvvmConfiguration CreateConfiguration(Action <IServiceCollection> customServices = null) => DotvvmConfiguration.CreateDefault(s => { customServices?.Invoke(s); RegisterMoqServices(s); });
private void ConfigureRoutes(DotvvmConfiguration config, string applicationPath) { config.RouteTable.Add("_Default", "", "Views/_default.dothtml"); config.RouteTable.AutoDiscoverRoutes(new SamplesRouteStrategy(config)); }
public BindingCompiler(DotvvmConfiguration configuration) { this.configuration = configuration; }
public SamplesRouteStrategy(DotvvmConfiguration config) : base(config) { }
public BindingPropertyResolvers(IBindingExpressionBuilder bindingParser, StaticCommandBindingCompiler staticCommandBindingCompiler, JavascriptTranslator javascriptTranslator, DotvvmConfiguration configuration) { this.configuration = configuration; this.bindingParser = bindingParser; this.staticCommandBindingCompiler = staticCommandBindingCompiler; this.javascriptTranslator = javascriptTranslator; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDotvvmViewBuilder"/> class. /// </summary> public DefaultDotvvmViewBuilder(DotvvmConfiguration configuration) { markupFileLoader = configuration.ServiceLocator.GetService <IMarkupFileLoader>(); controlBuilderFactory = configuration.ServiceLocator.GetService <IControlBuilderFactory>(); }
private void ConfigureControls(DotvvmConfiguration config, string applicationPath) { // register code-only controls and markup controls config.Markup.AutoDiscoverControls(new DefaultControlRegistrationStrategy(config, "controls", "Controls")); }
private DotvvmConfiguration ApplyPatches(params JObject[] patches) => ApplyPatches(DotvvmConfiguration.CreateDefault(), patches);
public static ViewModelValidationError CreateModelError <T, TProp>(DotvvmConfiguration config, Expression <Func <T, TProp> > expr, string error) => CreateModelError(config, (LambdaExpression)expr, error);
/// <summary> /// Initializes a new instance of the <see cref="DotvvmMiddleware" /> class. /// </summary> public DotvvmMiddleware(OwinMiddleware next, DotvvmConfiguration configuration, IList <IMiddleware> middlewares) : base(next) { Configuration = configuration; this.middlewares = middlewares; }
public static ValidationResult CreateValidationResult <T>(DotvvmConfiguration config, string error, params Expression <Func <T, object> >[] expressions) => CreateValidationResult(config, error, (LambdaExpression[])expressions);
public void Configure(DotvvmConfiguration config, string applicationPath) { config.RouteTable.Add("SampleA", "SampleA", "SampleA.dothtml", null); }
public static ViewModelValidationError CreateModelError(DotvvmConfiguration config, LambdaExpression expr, string error) => new ViewModelValidationError { ErrorMessage = error, PropertyPath = GetPathFromExpression(config, expr) };
private void ConfigureControls(DotvvmConfiguration config, string applicationPath) { // register code-only controls and markup controls }
public static ValidationResult CreateValidationResult(DotvvmConfiguration config, string error, LambdaExpression[] expr) => new ValidationResult( error, expr.Select(e => GetPathFromExpression(config, e)).ToArray() );
// For more information about this class, visit https://dotvvm.com/docs/tutorials/basics-project-structure public void Configure(DotvvmConfiguration config, string applicationPath) { ConfigureRoutes(config, applicationPath); ConfigureControls(config, applicationPath); ConfigureResources(config, applicationPath); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.UseCookieAuthentication(new CookieAuthenticationOptions { LoginPath = new PathString("/ComplexSamples/Auth/Login"), AuthenticationScheme = "Scheme1" }); app.UseCookieAuthentication(new CookieAuthenticationOptions { LoginPath = new PathString("/ComplexSamples/SPARedirect/login"), AuthenticationScheme = "Scheme2" }); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Scheme3" }); // app.UseMiddleware<SwitchMiddleware>( // new List<SwitchMiddlewareCase>() { // new SwitchMiddlewareCase( // c => c.Request.Uri.PathAndQuery.StartsWith("/ComplexSamples/Auth"), next => // new CookieAuthenticationMiddleware(next, app, new CookieAuthenticationOptions() // { // LoginPath = new PathString("/ComplexSamples/Auth/Login"), //AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme, // Provider = new CookieAuthenticationProvider() // { // OnApplyRedirect = c => // { // // redirect to login page on 401 request // if (c.Response.StatusCode == 401 && c.Request.Method == "GET") // { // c.Response.StatusCode = 302; // c.Response.Headers["Location"] = c.RedirectUri; // } // // do not do anything on redirection to returnurl // // to not return page when ViewModel is expected // // we should implement this in DotVVM framework, // // not samples // } // } // }) // ), // new SwitchMiddlewareCase( // c => c.Request.Uri.PathAndQuery.StartsWith("/ComplexSamples/SPARedirect"), next => // new CookieAuthenticationMiddleware(next, app, new CookieAuthenticationOptions() // { // LoginPath = new PathString("/ComplexSamples/SPARedirect/login"), // AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, // Provider = new CookieAuthenticationProvider() // { // OnApplyRedirect = c => // { // // redirect to login page on 401 request // if (c.Response.StatusCode == 401 && c.Request.Method == "GET") // { // c.Response.StatusCode = 302; // c.Response.Headers["Location"] = c.RedirectUri; // } // // do not do anything on redirection to returnurl // // to not return page when ViewModel is expected // // we should implement this in DotVVM framework, // // not samples // } // } // }) // ), // new SwitchMiddlewareCase( // c => c.Request.Uri.PathAndQuery.StartsWith("/ControlSamples/AuthenticatedView") // || c.Request.Uri.PathAndQuery.StartsWith("/ControlSamples/RoleView"), next => // new CookieAuthenticationMiddleware(next, app, new CookieAuthenticationOptions() // { // AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie // }) // ), // } // ); var applicationPhysicalPath = env.ContentRootPath; // use DotVVM DotvvmConfiguration dotvvmConfiguration = app.UseDotVVM <DotvvmStartup>(applicationPhysicalPath); dotvvmConfiguration.Debug = true; // use static files app.UseStaticFiles(new StaticFileOptions { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(applicationPhysicalPath) }); }