public ExecutionFilterComposite(IExecutionFilter filter, IPredication predication) { if(filter == null) throw new ArgumentNullException("filter"); _filter = filter; _predication = predication; }
public ExecutionFilterComposite(IExecutionFilter filter, IPredication predication) { if (filter == null) { throw new ArgumentNullException("filter"); } _filter = filter; _predication = predication; }
public override object Parse(ParserContext context) { if (string.IsNullOrWhiteSpace(context.Text)) { throw new PluginException("Can not parse for the predication because the parser text is empty."); } var matches = _regex.Matches(context.Text); if (matches.Count < 1) { throw new PluginException("Can not parse for the predication."); } var parts = matches[0].Value.Split('.'); if (parts.Length != 2) { throw new PluginException("Can not parse for the predication because of a syntax error."); } IPredication predication = null; if (parts.Length == 1) { predication = context.PluginContext.ApplicationContext.ServiceFactory.Default.Resolve(parts[0]) as IPredication; } else { var serviceProvider = context.PluginContext.ApplicationContext.ServiceFactory.GetProvider(parts[0]); if (serviceProvider == null) { throw new PluginException(string.Format("The '{0}' ServiceProvider is not exists on the predication parsing.", parts[0])); } predication = serviceProvider.Resolve(parts[1]) as IPredication; } if (predication != null) { string text = matches.Count <= 1 ? null : context.Text.Substring(matches[1].Index); object parameter = text; if (Zongsoft.Common.TypeExtension.IsAssignableFrom(typeof(IPredication <PluginPredicationContext>), predication.GetType())) { parameter = new PluginPredicationContext(text, context.Builtin, context.Node, context.Plugin); } return(predication.Predicate(parameter)); } return(false); }
public ExecutionPipeline Add(IExecutionHandler handler, IPredication predication = null) { if (handler == null) { throw new ArgumentNullException("handler"); } var item = new ExecutionPipeline(handler, predication); base.Add(item); return(item); }
public ExecutionFilterComposite Add(IExecutionFilter filter, IPredication predication) { if (filter == null) { throw new ArgumentNullException("filter"); } var result = new ExecutionFilterComposite(filter, predication); base.Add(result); return(result); }
protected CommandBase(string name, bool enabled) { _enabled = enabled; _predication = null; this.Name = string.IsNullOrWhiteSpace(name) ? Common.StringExtension.TrimStringEnd(this.GetType().Name, "Command", StringComparison.OrdinalIgnoreCase) : name; }
public ExecutionPipeline(IExecutionHandler handler, IPredication predication = null) { _handler = handler; _predication = predication; }
public PredicationFilter(IPredication predication, Context context) : base(context) => Predication = predication;