Пример #1
0
        public static T GetRequiredItem <T>(this IItemsHolder pipelineContext, string key)
            where T : class
        {
            if (!pipelineContext.TryGetItem <T>(key, out var item))
            {
                Require.Fail($"Could not get required item: {key}");
            }

            return(item);
        }
Пример #2
0
        public static void ReplaceTokens(this IItemsHolder pipelineContext, JToken doc, IDictionary <string, IReadOnlyCollection <string> > groups)
        {
            if (!pipelineContext.TryGetItem("TokenGroups", out IDictionary <string, IDictionary <string, int> > tokenGroups))
            {
                tokenGroups = new Dictionary <string, IDictionary <string, int> >();
                pipelineContext.SetItem("TokenGroups", tokenGroups);
            }

            Replace(doc, groups, new TokenHolder(tokenGroups));
        }
Пример #3
0
 public static T GetItem <T>(this IItemsHolder pipelineContext, string key)
     where T : class
 {
     pipelineContext.TryGetItem <T>(key, out var item);
     return(item);
 }
Пример #4
0
 public bool TryGetItem <T>(string key, out T item)
 {
     return(_itemsHolder.TryGetItem(GetEffectiveItemKey(key), out item));
 }