Ejemplo n.º 1
0
 public ResourceRepositoryMiddleware(RequestDelegate next, IServiceProvider services, IOptions <ResourceRepositoryOptions> options)
 {
     _next               = next;
     _options            = options.Value;
     _oicConfiguration   = services.GetRequiredService <OicConfiguration>();
     _resourceRepository = _options.ResourceRepository
                           ?? (_options.ResourceRepositoryType != null
                             ? (IOicResourceRepository)ActivatorUtilities.CreateInstance(services, _options.ResourceRepositoryType, _options.ResourceRepositoryArgs)
                             : ActivatorUtilities.CreateInstance <DefaultResourceRepository>(services));
 }
Ejemplo n.º 2
0
        public ResourceRepositoryContext(OicContext context, ResourceRepositoryOptions options, IOicResourceRepository resourceProvider)
        {
            _context          = context ?? throw new ArgumentNullException(nameof(context));
            _options          = options ?? throw new ArgumentNullException(nameof(options));
            _resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));

            // Since request path is a segment, ensure it is surrounded with slashes.
            _requestPath = _options.RequestPath ?? "/";
            if (!_requestPath.EndsWith("/"))
            {
                _requestPath += "/";
            }
            if (!_requestPath.StartsWith("/"))
            {
                _requestPath = "/" + _requestPath;
            }
        }