コード例 #1
0
        /// <summary>
        /// Adds the assembly.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="assembly">The assembly.</param>
        /// <param name="predicate">The predicate.</param>
        /// <returns>IPipeline&lt;T, TOut&gt;.</returns>
        public static IPipeline <T, TOut> AddAssembly <T, TOut>(
            this IPipeline <T, TOut> pipeline,
            Assembly assembly,
            Func <Type, bool> predicate)
        {
            var filterTypes = _pipelineTypes.GetOrAdd(Tuple.Create(assembly.FullName, typeof(T).FullName, typeof(TOut).FullName), q => assembly
                                                      .GetTypes()
                                                      .Where(t => typeof(IFilter <T, TOut>).IsAssignableFrom(t))
                                                      .Where(predicate)
                                                      .OrderBy(t => (((FilterOrderAttribute)Attribute.GetCustomAttribute(t, typeof(FilterOrderAttribute)))?.Order).GetValueOrDefault())
                                                      .ToList());;

            foreach (var filterType in filterTypes)
            {
                pipeline = pipeline.Add(filterType);
            }

            return(pipeline);
        }
コード例 #2
0
 /// <summary>
 /// Adds ASP.NET Core authorization code flow to <paramref name="pipeline" />.
 /// Depends on <see cref="ISystemClock" />, <see cref="IHttpContextAccessor" /> and <see cref="IOptionsMonitor{SpotifyOptions}"/>> that are registered by ASP.NET Core middleware.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="authenticationScheme">The authentication scheme.</param>
 /// <param name="spotifyAuthenticationScheme">The Spotify authentication scheme.</param>
 /// <returns></returns>
 public static IPipeline AddAspNetCoreAuthorizationCodeFlow(
     this IPipeline pipeline,
     string authenticationScheme        = null,
     string spotifyAuthenticationScheme = null)
 => pipeline.Add(new AspNetCoreAuthorizationCodeFlowPipelineItem(authenticationScheme, spotifyAuthenticationScheme));
コード例 #3
0
 /// <summary>
 /// Finallies the specified action.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="action">The action.</param>
 /// <returns>IPipeline&lt;T&gt;.</returns>
 public static IPipeline <T> Finally <T>(this IPipeline <T> pipeline, Func <T> action)
 {
     return(pipeline.Add(new FuncShortCircuit <T>(action)));
 }
コード例 #4
0
 /// <summary>
 /// Convenience method to add a short-circuiting filter to the end of the chain
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="func">The function.</param>
 /// <returns>IPipeline&lt;T, TOut&gt;.</returns>
 public static IPipeline <T, TOut> Finally <T, TOut>(this IPipeline <T, TOut> pipeline, Func <T, TOut> func)
 {
     return(pipeline.Add(new ShortCircuit <T, TOut>(func)));
 }
コード例 #5
0
 /// <summary>
 /// Adds UWP authorization code flow to <paramref name="pipeline" />.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="configureOptions">The configure options action.</param>
 /// <returns></returns>
 public static IPipeline AddUwpAuthorizationCodeFlow(this IPipeline pipeline, Action <UwpAuthorizationCodeFlowOptions> configureOptions)
 => pipeline.Add(new UwpAuthorizationCodeFlowPipelineItem(configureOptions));
コード例 #6
0
 public void Update(IPipeline pipeline)
 {
     pipeline.Add <PrepareConfiguration>();
     pipeline.Add <MakeSomeActionBaseOnConfiguration>();
 }
コード例 #7
0
 public void Update(IPipeline pipeline)
 {
     pipeline.Add <ConfigureAppWhenInMemoryStorage>();
     pipeline.Add <ConfigureAppWhenFileStorage>();
 }
コード例 #8
0
 /// <summary>
 /// Adds client credentials flow to <paramref name="pipeline" />.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="configureOptions">The options configuration action.</param>
 /// <returns></returns>
 public static IPipeline AddClientCredentialsFlow(this IPipeline pipeline, Action <ClientCredentialsFlowOptions> configureOptions = null)
 => pipeline.Add(new ClientCredentialsFlowPipelineItem(configureOptions));
コード例 #9
0
 /// <summary>
 /// Adds a delegate to the client execution chain.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="func">The delegate that will be executed during client call.</param>
 /// <returns></returns>
 public static IPipeline AddDelegate(
     this IPipeline pipeline,
     Func <Func <CancellationToken, Task <object> >, CancellationToken, Task <object> > func)
 {
     return(pipeline.Add(new DelegatedPipelineItem((next, httpRequest, resultType, cancellationToken) => func(innerCt => next(httpRequest, innerCt), cancellationToken))));
 }
コード例 #10
0
 /// <summary>
 /// Adds a delegate to the client execution chain.
 /// The parameter of HttpRequest type can be used to inspect and modify HTTP request.
 /// The <see cref="Type"/> parameter contains the type of the HTTP request result.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="func">The delegate that will be executed during client call.</param>
 /// <returns></returns>
 public static IPipeline AddDelegate(
     this IPipeline pipeline,
     Func <Func <HttpRequest <object>, CancellationToken, Task <object> >, HttpRequest <object>, Type, CancellationToken, Task <object> > func)
 {
     return(pipeline.Add(new DelegatedPipelineItem(func)));
 }