Add alias for dictionary type

This commit is contained in:
Sipke Schoorstra 2023-03-07 22:02:46 +01:00
parent db9962945b
commit 83fb433ffc
4 changed files with 12 additions and 19 deletions

View file

@ -32,6 +32,7 @@ public class WellKnownTypeRegistry : IWellKnownTypeRegistry
this.RegisterType<TimeOnly>("TimeOnly");
this.RegisterType<ExpandoObject>("ExpandoObject");
this.RegisterType<IDictionary<string, string>>("StringDictionary");
this.RegisterType<IDictionary<string, object>>("ObjectDictionary");
}
/// <inheritdoc />

View file

@ -9,6 +9,7 @@ using Elsa.Workflows.Core.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
namespace Elsa.Http;
@ -64,19 +65,19 @@ public class HttpEndpoint : Trigger<HttpRequest>
/// The parsed route data, if any.
/// </summary>
[Output(Description = "The parsed route data, if any.")]
public Output<Dictionary<string,object>> RouteData { get; set; } = default!;
public Output<IDictionary<string, object>> RouteData { get; set; } = default!;
/// <summary>
/// The querystring data, if any.
/// </summary>
[Output(Description = "The querystring data, if any.")]
public Output<Dictionary<string, object>> QueryStringData { get; set; } = default!;
public Output<IDictionary<string, object>> QueryStringData { get; set; } = default!;
/// <summary>
/// The headers, if any.
/// </summary>
[Output(Description = "The headers, if any.")]
public Output<Dictionary<string, object>> Headers { get; set; } = default!;
public Output<IDictionary<string, object>> Headers { get; set; } = default!;
/// <inheritdoc />
protected override IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => GetBookmarkPayloads(context.ExpressionExecutionContext);
@ -157,22 +158,9 @@ public class HttpEndpoint : Trigger<HttpRequest>
var path = context.GetInput<PathString>(RequestPathInputKey);
var routeData = GetRouteData(httpContext, path);
var routeDictionary = new Dictionary<string, object>();
foreach (var route in routeData.Values) {
routeDictionary.Add(route.Key, route.Value);
}
var queryStringDictionary = new Dictionary<string, object>();
foreach (var queryString in httpContext.Request.Query)
{
queryStringDictionary.Add(queryString.Key, queryString.Value[0]);
}
var headersDictionary = new Dictionary<string, object>();
foreach (var header in httpContext.Request.Headers)
{
headersDictionary.Add(header.Key, header.Value[0]);
}
var routeDictionary = routeData.Values.ToDictionary(route => route.Key, route => route.Value);
var queryStringDictionary = httpContext.Request.Query.ToDictionary<KeyValuePair<string, StringValues>, string, object>(queryString => queryString.Key, queryString => queryString.Value[0]!);
var headersDictionary = httpContext.Request.Headers.ToDictionary<KeyValuePair<string, StringValues>, string, object>(header => header.Key, header => header.Value[0]!);
context.Set(RouteData, routeDictionary);
context.Set(QueryStringData, queryStringDictionary);

View file

@ -71,6 +71,7 @@ public class WorkflowManagementFeature : FeatureBase
new(typeof(DateOnly), PrimitivesCategory, "Represents dates with values ranging from January 1, 0001 Anno Domini (Common Era) through December 31, 9999 A.D. (C.E.) in the Gregorian calendar."),
new(typeof(TimeOnly), PrimitivesCategory, "Represents a time of day, as would be read from a clock, within the range 00:00:00 to 23:59:59.9999999."),
new(typeof(IDictionary<string, string>), LookupsCategory, "A dictionary with string key and values."),
new(typeof(IDictionary<string, object>), LookupsCategory, "A dictionary with string key and object values."),
new (typeof(ExpandoObject), DynamicCategory, "A dictionary that can be typed as dynamic to access members using dot notation."),
new (typeof(JsonObject), DynamicCategory, "A type from System.Text.Json that provides dynamic access to the object.")
};

View file

@ -2,6 +2,9 @@ using Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Management.Options;
/// <summary>
/// Options for the management module.
/// </summary>
public class ManagementOptions
{
/// <summary>