Exemplo n.º 1
0
        public static string GetRequiredItem(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            return(item switch
            {
                null => null,
                string stringValue => stringValue,
                JToken jtokenValue => JsonConvert.SerializeObject(jtokenValue),
                _ => throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into string"),
            });
Exemplo n.º 2
0
        public static string GetRequiredItem(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            switch (item)
            {
            case null:
                return(null);

            case string stringValue:
                return(stringValue);

            case JToken jtokenValue:
                return(JsonConvert.SerializeObject(jtokenValue));

            default:
                throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into string");
            }
        }
Exemplo n.º 3
0
        public static JToken GetRequiredItemAsJToken(this IItemsHolder pipelineContext, string key)
        {
            var item = pipelineContext.GetRequiredItem <object>(key);

            switch (item)
            {
            case null:
                return(null);

            case string stringValue:
                return(JToken.Parse(stringValue));

            case JToken jtokenValue:
                return(jtokenValue);

            case object obj:
                return(JObject.FromObject(obj));

            default:
                throw new NotSupportedException($"Unsupported item type {item.GetType()} for conversion into JToken");
            }
        }
Exemplo n.º 4
0
 public static string Resolve(this IItemsHolder pipelineContext, string value)
 {
     return(VariableResolver.Resolve(value, (key) => pipelineContext.GetRequiredItem(key)));
 }