Example #1
0
 public BibaMiddleware(RequestDelegate next, BibaCompiler compiler, BibaViewEngineProperties props, IBibaRouter router)
 {
     _compiler = compiler;
     _next     = next;
     _props    = props;
     _router   = router;
 }
Example #2
0
        public static IServiceCollection AddBibaViewEngine <EntryComponent>(this IServiceCollection services,
                                                                            Routes routes = null, Action <BibaViewEngineProperties> propsAct = null) where EntryComponent : Component
        {
            var tags = GetRegisterTags();

            tags = tags.Concat(new string[] { "#text", "#comment" });

            var props = new BibaViewEngineProperties();

            propsAct?.Invoke(props);

            var components = new ComponentTypes(Assembly.Load("BibaViewEngine").GetTypes().Where(x => x.BaseType == typeof(Component))
                                                .Concat(Assembly.GetCallingAssembly().GetTypes().Where(x => x.BaseType == typeof(Component))));

            InitRoutes(out Routes outRoutes, routes);

            foreach (var component in components)
            {
                services.AddTransient(component);
            }

            services.AddRouting();

            services.AddSingleton(outRoutes);
            services.AddSingleton(props);
            services.AddSingleton(new RegistesteredTags(tags));
            services.AddSingleton(components);
            services.AddScoped <RouterData>();
            services.AddSingleton(new CurrentRoute {
                Route = new BibaRoute()
            });

            services.AddTransient <BibaCompiler>();
            services.AddTransient <IBibaRouter, BibaRouter>();
            services.AddTransient <Component, EntryComponent>();
            services.AddScoped <IAuthorizationHandler, BibaAuthorizationHandler>();

            services.AddAuthorization(opts =>
            {
                opts.AddPolicy("BibaScheme", builder =>
                {
                    builder.AddRequirements(new DefaultRequirement());
                    builder.Build();
                });
            });

            return(services);
        }
        public static IServiceCollection AddBibaViewEngine <EntryComponent>(this IServiceCollection services,
                                                                            Routes routes = null, BibaViewEngineProperties props = null) where EntryComponent : Component
        {
            var tags = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <string> >(registeredTags);

            tags = tags.Concat(new string[] { "#text", "#comment" });
            Routes outRoutes;

            if (props == null)
            {
                props = new BibaViewEngineProperties();
            }

            var components = new ComponentTypes(Assembly.Load("BibaViewEngine").GetTypes().Where(x => x.BaseType == typeof(Component))
                                                .Concat(Assembly.GetEntryAssembly().GetTypes().Where(x => x.BaseType == typeof(Component))));

            InitRoutes(out outRoutes, routes);

            foreach (var component in components)
            {
                services.AddTransient(component);
            }

            services.AddRouting();

            services.AddSingleton(outRoutes);
            services.AddSingleton(props);
            services.AddSingleton <BibaViewEngineProperties>();
            services.AddSingleton(new RegistesteredTags(tags));
            services.AddSingleton(components);
            services.AddTransient <BibaCompiler>();
            services.AddTransient <IBibaRouter, BibaRouter>();
            services.AddTransient <Component, EntryComponent>();

            return(services);
        }
Example #4
0
 public IndexHtmlNotExistsException(BibaViewEngineProperties props)
 {
     _props = props;
 }
 public BibaMiddleware(RequestDelegate next, BibaViewEngineProperties props)
 {
     _props = props;
 }