/// <inheritdoc/>
        public IValueConverter GetConverterFor(Type type)
        {
            var valueConverter = _converters.FirstOrDefault(_ => _.CanConvert(type));

            ThrowIfMissingValueConverter(type, valueConverter);
            return(valueConverter);
        }
Пример #2
0
        IAsyncPolicy DefineDefaultAsyncPolicy()
        {
            var underlyingPolicy = _defaultAsyncPolicyDefiners.FirstOrDefault()?.Define();
            var policy           = underlyingPolicy != null ? (IAsyncPolicy) new AsyncPolicy(underlyingPolicy) : new PassThroughAsyncPolicy();

            return(policy);
        }
Пример #3
0
        IPolicy DefineDefaultPolicy()
        {
            ThrowIfMultipleDefaultPoilicyDefinersAreFound();
            var underlyingPolicy = _defaultPolicyDefiners.FirstOrDefault()?.Define();
            var policy           = underlyingPolicy != null ? (IPolicy) new Policy(underlyingPolicy) : new PassThroughPolicy();

            return(policy);
        }
Пример #4
0
        public IActionResult Export(DownloadParameters parameters)
        {
            _executionContextConfigurator.ConfigureFor(_tenantResolver.Resolve(HttpContext.Request), Dolittle.Execution.CorrelationId.New(), ClaimsPrincipal.Current.ToClaims());

            var exporter = _exporters.FirstOrDefault(_ => _.Format == parameters.Format);

            if (exporter != null)
            {
                var reports  = _allCaseReports().Query;
                var filtered = reports.Where(parameters.FilterPredicate);
                var ordered  = parameters.OrderDescending ? filtered.OrderByDescending(parameters.GetOrderByPredicate) : filtered.OrderBy(parameters.GetOrderByPredicate);

                var fileName = "CaseReports-" + DateTimeOffset.UtcNow.ToString("yyyy-MM-dd") + exporter.FileExtension;

                var stream = new MemoryStream();
                exporter.WriteReportsTo(ordered, stream);
                stream.Position = 0;
                return(File(stream, exporter.MIMEType, fileName));
            }
            else
            {
                return(NotFound());
            }
        }