/// <summary> /// Initializes a new instance of the <see cref="From"/> class. /// </summary> /// <param name="fromComponent">From component to use.</param> /// <param name="next">Next processing component.</param> /// <param name="logger">Logger class.</param> /// <param name="id">Identity of the route.</param> /// <param name="isAtomicRoute">Value indicating whether the route is atomic.</param> public From(IFromComponent fromComponent, IChain <Routable> next, ILogger logger, string id, bool isAtomicRoute = false) { this.fromComponent = fromComponent; this.fromComponent.Setup(); this.fromComponent.OnAction += this.FromComponent_OnAction; this.next = next; this.logger = logger; this.fromComponent.OnLog += this.FromComponent_OnLog; this.identity = id; this.IsAtomicRoute = isAtomicRoute; }
/// <summary> /// Creates the from component. /// </summary> /// <param name="from">Valid component name.</param> /// <param name="headers">Dictionary of headers</param> /// <param name="serviceProvider">DI Service provider.</param> /// <param name="isAtomic">Indicates if the route is atomic.</param> /// <returns>Returns an instance of the <see cref="IFromComponent"/> interface.</returns> protected IFromComponent CreateFrom(string from, Dictionary <string, string> headers, IServiceProvider serviceProvider, bool isAtomic = false) { IFromComponent response = null; try { response = this.GetOasis(from).CreateFromComponent(headers, isAtomic, serviceProvider); } catch (Exception ex) { throw new Exceptions.ActivationException(Resources.ERROR_ACTIVATION_FROM, ex, "From"); } return(response); }
/// <summary> /// Builds the final chain into dependency injection. /// </summary> /// <param name="services">Service collection.</param> public void Build(IServiceCollection services) { this.RunComponentDiRegistration(services); services.AddTransient <IHostedService>(x => { IFromComponent from = this.CreateFrom(this.fromUri.ComponentName, this.fromUri.Headers, x, this.IsAtomic); ILogger logger = x.GetService <ILogger <Route> >(); logger.LogInformation(Resources.INFO_SETTINGUPROUTE); IChain <Routable> next = null; IChain <Routable> toChain = this.SetupToChain(0, logger, x); if (this.components != null && this.components.Count > 0) { next = SetupChain(0, logger, toChain, x); } else { next = toChain; } return(new Chain.From(from, next, logger, this.identity)); }); }