public static void AddCatalog(this IPaperCatalog baseCatalog, IPaperCatalog paperCatalog)
        {
            var aggregateCatalog = baseCatalog as AggregateCatalog;

            if (aggregateCatalog == null)
            {
                throw new Exception($"O catálogo base {baseCatalog.GetType().FullName} não suporta o mapeamento de um subcatálogo.");
            }

            aggregateCatalog.AddCatalog(paperCatalog);
        }
Example #2
0
        public PaperContext(IInjector injector, object paper, IPaperCatalog catalog, string requestUri)
        {
            requestUri = SanitizeRequestUri(requestUri);

            var paperSpec = PaperSpec.GetSpec(paper as Type ?? paper.GetType());
            var template  = paperSpec.UriTemplate;
            var prefix    = ApiPrefix ?? "";

            if (!prefix.StartsWith("/"))
            {
                prefix = "/" + prefix;
            }
            while (prefix.EndsWith("/"))
            {
                prefix = prefix.Substring(0, prefix.Length - 1);
            }

            if (!template.StartsWith("/"))
            {
                template = "/" + template;
            }
            while (template.EndsWith("/"))
            {
                template = template.Substring(0, template.Length - 1);
            }

            var composedTemplate = $"{prefix}{template}";

            var uriTemplate = new UriTemplate(template);

            uriTemplate.SetArgsFromUri(requestUri);

            var args = uriTemplate.CreateArgs();

            this.Injector     = injector;
            this.Paper        = paper;
            this.PaperCatalog = catalog;
            this.RequestUri   = requestUri;
            this.UriTemplate  = template;
            this.PathArgs     = args;
        }
Example #3
0
 public CatalogPipeline(IWebApp webApp, IPaperCatalog paperCatalog, IObjectFactory objectFactory)
 {
     this.defaultCatalog = webApp.Name;
     this.paperCatalog   = paperCatalog;
     this.objectFactory  = objectFactory;
 }
Example #4
0
 public PaperRenderer2(IObjectFactory objectFactory, IPaperCatalog paperCatalog)
 {
     this.objectFactory = objectFactory;
     this.paperCatalog  = paperCatalog;
 }
Example #5
0
 public PaperPipeline(IObjectFactory objectFactory, IPaperCatalog paperCatalog)
 {
     this.objectFactory = objectFactory;
     this.paperCatalog  = paperCatalog;
 }
Example #6
0
 public PaperMiddleware(RequestDelegate next, IPaperCatalog catalog)
 {
     this.next    = next;
     this.catalog = catalog;
 }