| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using Inversion;
- using Astralis;
- namespace Spry {
- public class SpryModule : Object, Module {
- public void register_components (Container container) throws Error {
- container.register_singleton<PathProvider>();
- container.register_startup<CryptographyProvider>();
- container.register_startup<ComponentContextService>();
- container.register_scoped<ComponentFactory>();
- container.register_scoped<Authorisation.AuthorisationService>();
- container.register_scoped<Authorisation.AuthorisationPipelineComponent>()
- .as<PipelineComponent>();
- container.register_startup<ContinuationProvider>()
- .as<Endpoint>()
- .with_metadata<EndpointRoute>(new EndpointRoute("/_spry/cnu/{token}"));
- container.register_startup<StaticResourceProvider>()
- .as<Endpoint>()
- .with_metadata<EndpointRoute>(new EndpointRoute("/_spry/res/{resource}"));
- container.register_scoped<ComponentEndpoint>()
- .as<Endpoint>()
- .with_metadata<EndpointRoute>(new EndpointRoute("/_spry/com/{component-id}/{action}"))
- .with_metadata<EndpointRoute>(new EndpointRoute("/_spry/com/{component-id}/{action}/{context}"));
- container.register_startup<Static.HtmxResource>()
- .as<Spry.StaticResource>();
- container.register_startup<Static.HtmxSseResource>()
- .as<Spry.StaticResource>();
- }
- }
- public class SpryConfigurator : Object {
- private Container container = inject<Container>();
- public void add_template<T>(string prefix) {
- container.register_transient<T>()
- .as<PageTemplate> ()
- .with_metadata<TemplateRoutePrefix>(new TemplateRoutePrefix(prefix));
- }
- public void add_page<T>(EndpointRoute route) {
- container.register_scoped<T>()
- .as<Endpoint>()
- .with_metadata<EndpointRoute>(route);
- }
- public void add_resource<T>() {
- container.register_startup<T>()
- .as<Spry.StaticResource>();
- }
- public void add_component<T>() {
- container.register_transient<T>();
- }
- }
- }
|