예제 #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"),
            });
예제 #2
0
파일: IItemsHolder.cs 프로젝트: tudway/Qart
        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");
            }
        }
예제 #3
0
파일: IItemsHolder.cs 프로젝트: tudway/Qart
        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");
            }
        }
예제 #4
0
파일: IItemsHolder.cs 프로젝트: tudway/Qart
 public static string Resolve(this IItemsHolder pipelineContext, string value)
 {
     return(VariableResolver.Resolve(value, (key) => pipelineContext.GetRequiredItem(key)));
 }