public async Task Invoke(HttpContext context, IFluentContext fluent)
        {
            var requestHeaders = context.Request.Headers;

            foreach (var header in _headers)
            {
                if (requestHeaders.ContainsKey(header))
                {
                    Guid headerValue;
                    if (Guid.TryParse(requestHeaders[header], out headerValue))
                    {
                        fluent.CorrelationId = headerValue;
                        _logger.LogInformation($"An existing Correlation Id {fluent.CorrelationId} was found in request header {header}");
                        break;
                    }
                }
            }

            // If a correlation id cannot be found in the request headers
            // Treat as new request with no prior dealings
            if (fluent.CorrelationId == Guid.Empty)
            {
                fluent.CorrelationId = Guid.NewGuid();
                _logger.LogInformation($"A new Correlation Id {fluent.CorrelationId} was generated for this request");
            }

            // Call the next delegate/middleware in the pipeline
            await _next(context);
        }
 public BuilderParameters(DirectoryPath rootPath, DirectoryPath buildPath, DirectoryPath artifactsPath, IFluentContext context, IConfiguration rootConfiguration, IConfiguration switchConfiguration, IReadOnlyDictionary <string, IPlatformConfiguration> platformsConfiguration, IReadOnlyDictionary <string, ITargetConfiguration> targetsConfiguration, IReadOnlyDictionary <string, IApplicationConfiguration> applicationsConfiguration)
 {
     RootPath                  = rootPath;
     BuildPath                 = buildPath;
     ArtifactsPath             = artifactsPath;
     Context                   = context;
     RootConfiguration         = rootConfiguration;
     SwitchConfiguration       = switchConfiguration;
     PlatformsConfiguration    = platformsConfiguration;
     TargetsConfiguration      = targetsConfiguration;
     ApplicationsConfiguration = applicationsConfiguration;
 }
示例#3
0
 /// <summary>
 /// Executes retry action
 /// </summary>
 /// <typeparam name="TArgument">Type of Argument of extension</typeparam>
 /// <param name="context">Context which proceeded by WithRetryFunc</param>
 /// <param name="func">The function which will be retried</param>
 public static void Retry <TArgument>(this IFluentContext <TArgument> context, Action <TArgument> func)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (func == null)
     {
         throw new ArgumentNullException(nameof(func));
     }
     context.RetryFunc(context.Argument, func);
 }
        public CalculationControllerV1(IFluentContext fluent,
                                       CommonResponses common,
                                       IHtmlLocalizer <Program> localizer) : base(fluent, common)
        {
            if (localizer == null)
            {
                throw new ArgumentNullException(nameof(localizer));
            }
            _localizer = localizer;

            _validator = new CalculationModelInputValidatior(fluent, localizer);
        }
示例#5
0
 /// <summary>
 /// Executes retry function
 /// </summary>
 /// <typeparam name="TArgument">Type of Argument of extension</typeparam>
 /// <typeparam name="TResult">Type of Result of the function</typeparam>
 /// <param name="context">Context which proceeded by WithRetryFunc</param>
 /// <param name="func">The function which will be retried</param>
 /// <returns>Result of the function or throw some exception</returns>
 /// <exception cref="ArgumentNullException">Context or func cannot be null</exception>
 public static TResult Retry <TArgument, TResult>(this IFluentContext <TArgument, TResult> context,
                                                  Func <TArgument, TResult> func)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (func == null)
     {
         throw new ArgumentNullException(nameof(func));
     }
     return(context.RetryFunc(context.Argument, func));
 }
示例#6
0
        public BaseApiController(IFluentContext fluent, CommonResponses common)
        {
            if (fluent == null)
            {
                throw new ArgumentNullException(nameof(fluent));
            }
            if (common == null)
            {
                throw new ArgumentNullException(nameof(common));
            }

            Fluent          = fluent;
            CommonResponses = common;
        }
        public CommonResponses(IFluentContext fluent, IHtmlLocalizer <CommonResponses> localizer)
        {
            if (fluent == null)
            {
                throw new ArgumentNullException(nameof(fluent));
            }
            if (localizer == null)
            {
                throw new ArgumentNullException(nameof(localizer));
            }

            _fluent    = fluent;
            _localizer = localizer;
        }
示例#8
0
        public CalculationModelInputValidatior(IFluentContext context, IHtmlLocalizer <Program> localizer)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localizer == null)
            {
                throw new ArgumentNullException(nameof(localizer));
            }

            _context   = context;
            _localizer = localizer;
        }
 public ApplicationConfiguration(IFluentContext context) : base(context)
 {
 }
 public ConfigurationBuilder(IFluentContext context)
 {
     _context           = context;
     _pathContainer     = new PathContainer();
     _rootConfiguration = new Configuration(context);
 }
示例#11
0
 private Configuration(IFluentContext context, Dictionary <string, IConfigurationItem> configurationItems, IEnumerable <IStep> steps) : this(context)
 {
     _configurationItems = configurationItems;
     _steps = new List <IStep>(steps);
 }
示例#12
0
 public Configuration(IFluentContext context) : base(context)
 {
 }
示例#13
0
 protected ContextAwareBase(IFluentContext context)
 {
     Context = context;
 }
示例#14
0
 public SwitchBuilder(IFluentContext context, string switchName)
 {
     _context    = context;
     _switchName = switchName;
 }
示例#15
0
 public PlatformConfiguration(IFluentContext context) : base(context)
 {
 }