public static Registry RegisterPlugins <TPlugin, TContext>(this Registry registry, ConditionalPlugins <TPlugin, TContext> plugins) where TPlugin : class { plugins.ForEach(x => registry.RegisterPlugin(x)); return(registry); }
public ConditionalPluginsDsl( ConditionalPlugins <TPlugin, TContext> plugins, Func <TContext, bool> defaultPredicate = null) { Plugins = plugins; DefaultPredicate = defaultPredicate; }
public static IContainer RegisterPlugins <TPlugin, TContext>(this IContainer container, ConditionalPlugins <TPlugin, TContext> plugins) where TPlugin : class { plugins.ForEach(x => container.RegisterPlugin(x)); return(container); }
public static IEnumerable <TPlugin> ThatAppliesTo <TPlugin, TPluginContext, TInstanceContext>( this ConditionalPlugins <TPlugin, TPluginContext> plugins, IEnumerable <TPlugin> instances, TPluginContext pluginContext, TInstanceContext instanceContext) where TPlugin : IConditional <TInstanceContext> { return(plugins.ThatApply(instances, pluginContext, x => x.AppliesTo(instanceContext))); }
public static IEnumerable <TPlugin> ThatAppliesOrDefault <TPlugin, TPluginContext>( this ConditionalPlugins <TPlugin, TPluginContext> plugins, IEnumerable <TPlugin> instances, TPluginContext pluginContext) where TPlugin : class, IConditional { return(plugins.ThatApplyOrDefault(instances, pluginContext, x => x.Applies())); }
private static IEnumerable <TPlugin> ThatApplyOrDefault <TPlugin, TPluginContext>( this ConditionalPlugins <TPlugin, TPluginContext> plugins, IEnumerable <TPlugin> instances, TPluginContext pluginContext, Func <TPlugin, bool> predicate) { return(plugins.ThatApply(instances, pluginContext, predicate).ToList() .AnyOrDefault(() => plugins.GetDefaultInstance(instances))); }
public ReplaceDsl(ConditionalPluginsDsl <TPlugin, TContext> dsl, ConditionalPlugins <TPlugin, TContext> plugins, Func <TContext, bool> defaultPredicate) { _dsl = dsl; _plugins = plugins; _defaultPredicate = defaultPredicate; }
private static IEnumerable <TPlugin> ThatApply <TPlugin, TPluginContext>( this ConditionalPlugins <TPlugin, TPluginContext> plugins, IEnumerable <TPlugin> instances, TPluginContext pluginContext, Func <TPlugin, bool> predicate) { return(plugins.ThatApplyTo(instances, pluginContext) .Where(x => predicate.Invoke(x.Instance)) .Select(x => x.Instance).ToList()); }
public static TPlugin FirstThatAppliesToOrDefault <TPlugin, TPluginContext, TInstanceContext>( this ConditionalPlugins <TPlugin, TPluginContext> plugins, IEnumerable <TPlugin> instances, TPluginContext pluginContext, TInstanceContext instanceContext) where TPlugin : class, IConditional <TInstanceContext> { return(plugins.ThatAppliesToOrDefault(instances, pluginContext, instanceContext).FirstOrDefault()); }
public PrependDsl(ConditionalPlugin <TPlugin, TContext> plugin, ConditionalPlugins <TPlugin, TContext> plugins, Func <TContext, bool> defaultPredicate) : base(plugins, defaultPredicate) { _plugin = plugin; }