Exemplo n.º 1
0
        /// <summary>
        /// Constructs the instance of <see cref="ActorLayerTestMiddleware"/>.
        /// </summary>
        /// <param name="next">The next request middleware handler.</param>
        /// <param name="options">The middleware parameters.</param>
        /// <param name="bigBrother">The telemetry sink.</param>
        public ActorLayerTestMiddleware(RequestDelegate next, ActorLayerTestMiddlewareOptions options, IBigBrother bigBrother)
        {
            _next       = next;
            _options    = options;
            _bigBrother = bigBrother;

            _actorMethods = new Lazy <Dictionary <string, ActorMethod> >(
                () => CreateActorMethodsDictionary(GetAssemblies(_options.InterfaceAssemblies)));

            _activeUntil = DateTime.UtcNow + _options.KillWindow;
        }
Exemplo n.º 2
0
        public static IApplicationBuilder UseActorLayerTestDirectCall(this IApplicationBuilder app, ActorLayerTestMiddlewareOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.StatelessServiceContext == null)
            {
                throw new ArgumentException("The StatelessServiceContext property must not be null", nameof(options));
            }

            if (options.PathPrefix.Value == null)
            {
                throw new ArgumentException("The PathPrefix property must not be null", nameof(options));
            }

            if (options.PathPrefix.Value.Length < 2 || options.PathPrefix.Value.EndsWith("/"))
            {
                throw new ArgumentException("The value of the PathPrefix property is invalid.", nameof(options));
            }

            if (string.IsNullOrWhiteSpace(options.AuthorizationPolicyName))
            {
                throw new ArgumentException("Authorization policy name must be set",
                                            nameof(options.AuthorizationPolicyName));
            }

            return(app.UseMiddleware <ActorLayerTestMiddleware>(options));
        }