public PropertyRule(RuleEngineContext.RuleEngineContext context, string rule, Func <TEntity, bool> rulefunc, Dictionary <PropertyHolder, Func <TEntity, bool> > properties, string name, string description = "", bool collectDiagnostic = true) : base(context, rule, rulefunc, name, description) { _properties = properties; this._collectDiagnostic = collectDiagnostic; }
private GroupChildRulesetPropertyRuleBuilder(RuleEngineContext.RuleEngineContext context, Func <TEntity, bool> rule1, string name, string description, RulesetBuilder <TEntity> ruleSetBuilder, GroupChildRuleSetBuilder <TEntity, TKey> groupChildRuleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) { this._groupChildRuleSetBuilder = groupChildRuleSetBuilder; _propertyBuilder = ruleSetBuilder.WithRule(rule1, name, description); }
public Func <TEntity, bool> ParserRule(RuleEngineContext.RuleEngineContext contex, string propertyName, string ruleExpression) { IPlaceHolderParser <TEntity> placeHolderParser = RuleExpressionParserFactory.CreatePalceHolderParser <TEntity>(); placeHolderParser.AddPlaceHolders(_placeholders); string strexpr = placeHolderParser.ParsePlaceHolder(contex, ruleExpression); string strexpression = "SetPropertyValue(" + "\"" + propertyName + "\"," + strexpr + ")"; try { var expression = DynamicExpressionParser.ParseLambda <TEntity, bool> (contex.EntityContextMetadata.GetRuleParserConfig(), true, strexpression); return(expression.Compile()); } catch (Exception ex) { throw new ExpressionParserException("PropertyRuleExpressionParser", ruleExpression, strexpression, contex.RuleEngineId, ex); } }
internal static GroupChildRulesetPropertyRuleBuilder <TEntity, TKey> Create (RuleEngineContext.RuleEngineContext context, Func <TEntity, bool> rule, string name, string description, RulesetBuilder <TEntity> ruleSetBuilder , GroupChildRuleSetBuilder <TEntity, TKey> groupChildRuleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) { return(new GroupChildRulesetPropertyRuleBuilder <TEntity, TKey> (context, rule, name, description, ruleSetBuilder, groupChildRuleSetBuilder, propertyparser)); }
private DefaultRuleBuilder(RuleEngineContext.RuleEngineContext contex, RulesetBuilder <TEntity> ruleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) : base(contex) { _ruleSetBuilder = ruleSetBuilder; _propertyparser = propertyparser; }
public DynamicGroupRuleSet(IEnumerable <IRuleset <TEntity> > ruleSets, EntryCriteriaRule <TEntity> entryPoint, IEnumerable <AggregatePropertyMetadata <TEntity> > aggregateProps, RuleEngineContext.RuleEngineContext context, string groupKey, string name, string description, IGroupKeyExpressionParser <TEntity> _groupKeyExpressionParser) : base(ruleSets, entryPoint, aggregateProps, context, groupKey, name, description) { _parsedExpression = _groupKeyExpressionParser.ParseGroupString(context, GroupKey); }
private GroupRuleSetBuilder(RuleEngineContext.RuleEngineContext context) { _ruleparser = RuleExpressionParserFactory.CreateStringRuleParser <TEntity>(); _propertyparser = RuleExpressionParserFactory.CreateStringPropertyRuleParser <TEntity>(); _groupKeyExpressionParser = RuleExpressionParserFactory.CreateGroupKeyParser <TEntity>(); this._context = context; }
internal static PropertyRuleBuilder <TEntity> Create(RuleEngineContext.RuleEngineContext context, string rule, IRuleExpressionParser <TEntity> ruleparser, IPropertyRuleExpressionParser <TEntity> propertyparser, RulesetBuilder <TEntity> ruleSetBuilder, string name, string description = "") { return(new PropertyRuleBuilder <TEntity>(context, rule, ruleparser, propertyparser, ruleSetBuilder, name, description)); }
private RulesetBuilder(RuleEngineContext.RuleEngineContext context) { _context = context; _ruleparser = RuleExpressionParserFactory.CreateStringRuleParser <TEntity>(); _propertyparser = RuleExpressionParserFactory .CreateStringPropertyRuleParser <TEntity>(); }
public AbstractRule(RuleEngineContext.RuleEngineContext context, string rule, Func <TEntity, bool> rulefunc, string name, string description) { _context = context; Rule = rule; Rulefunc = rulefunc; RuleName = name; RuleDescription = description; }
public LamdaGroupRuleSet (IEnumerable <IRuleset <TEntity> > ruleSets, EntryCriteriaRule <TEntity> entryPoint, IEnumerable <AggregatePropertyMetadata <TEntity> > aggregateProps, RuleEngineContext.RuleEngineContext context, Func <TEntity, TKey> keySelector, string name, string description) : base(ruleSets, entryPoint, aggregateProps, context, string.Empty, name, description) { _keySelector = keySelector; }
private GroupChildRulesetDefaultRuleBuilder(RuleEngineContext.RuleEngineContext context, RulesetBuilder <TEntity> ruleSetBuilder, GroupRuleSetBuilder <TEntity, TKey> groupRuleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) { this._ruleSetBuilder = ruleSetBuilder; this._groupRuleSetBuilder = groupRuleSetBuilder; _defaultProp = ruleSetBuilder.WithDefaultRule(); }
public AggregatePropertyMetadata(RuleEngineContext.RuleEngineContext context, string propertyName, AggregateFunction aggregateFunction, Type type, string aggregateOn) { AggregateFunction = aggregateFunction; Type = type; this._context = context; PropertyName = propertyName; PropertyExpression = aggregateOn; }
internal Ruleset(RuleEngineContext.RuleEngineContext context, IEnumerable <IPropertyRule <TEntity> > rules, EntryCriteriaRule <TEntity> entryPoint, RuleExecutionRuleEnum ruleExecutionRule, string name, string description) { this._context = context; this._entryPoint = entryPoint; this._ruleExecutionRule = ruleExecutionRule; Name = name; Description = description; _rules.AddRange(rules); }
public string ParsePlaceHolder(RuleEngineContext.RuleEngineContext context, string placeHolderExpression) { try { return(StringRulePLaceHolderParser.ParseRulePlaceHolder <TEntity>(context, placeHolderExpression, _placeholders)); } catch (System.Exception ex) { throw new ExpressionParserException("ParsePlaceHolder", placeHolderExpression, context.RuleEngineId, ex); } }
private PropertyRuleBuilder(RuleEngineContext.RuleEngineContext context, Func <TEntity, bool> rulefunc, IPropertyRuleExpressionParser <TEntity> propertyparser, RulesetBuilder <TEntity> ruleSetBuilder, string name, string description = "") : base(context) { this._rulefunc = rulefunc; _propertyparser = propertyparser; this._ruleSetBuilder = ruleSetBuilder; this._name = name; this._description = description; }
public Grouping(RuleEngineContext.RuleEngineContext context, IEnumerable <TEntity> entity, IEnumerable <AggregatePropertyMetadata <TEntity> > aggregateProps) { _aggregateProperties = new PropertyBag(BagType.Calculated, context.RootEntityType); _entityType = context.RootEntityType; Entity = entity; this._aggregateProps = aggregateProps; foreach (var item in aggregateProps) { var prop = RuleAwareEntityPropertyInfo.GetCalculatedProperty(_entityType, item.PropertyName); _aggregateProperties.Initialize(prop); _allProperties.Add(item.PropertyName); } CalculateAggregatePropertiesForGroup(entity); }
internal AbstractGroupRuleSet(IEnumerable <IRuleset <TEntity> > ruleSets, EntryCriteriaRule <TEntity> entryPoint, IEnumerable <AggregatePropertyMetadata <TEntity> > aggregateProps, RuleEngineContext.RuleEngineContext context, string groupKey, string name, string description) { this._entryPoint = entryPoint; Name = name; Description = description; GroupKey = groupKey; _aggregateProps = aggregateProps; this._context = context; _ruleSets = ruleSets; _executedRuleSet = new List <IRuleset <TEntity> >(); }
internal static string ParseRulePlaceHolder <TEntity>(RuleEngineContext.RuleEngineContext context, string ruleExpression, Dictionary <string, string> customplaceholders) where TEntity : RuleAwareEntity { PlaceHolderTextParser place = new PlaceHolderTextParser(ruleExpression); string placeHolder; string placeHolderWithParenthesis; while (place.NextPlaceHolder(out placeHolder, out placeHolderWithParenthesis)) { ParseRule <TEntity>(context.RootEntityType, context.EntityContextMetadata, ref ruleExpression, ref place, placeHolder, customplaceholders); } return(ruleExpression); }
private GroupChildRuleSetBuilder(RuleEngineContext.RuleEngineContext context, string name, string description, IRuleExpressionParser <TEntity> ruleparser, IPropertyRuleExpressionParser <TEntity> propertyparser, GroupRuleSetBuilder <TEntity, TKey> groupRuleSetBuilder) { this._context = context; _ruleparser = ruleparser; this._groupRuleSetBuilder = groupRuleSetBuilder; this._propertyparser = propertyparser; _ruleSetBuilder = RulesetBuilder <TEntity> .Create(context) .WithName(name) .WithDescription(description) .SetPropertyRuleParser(propertyparser) .SetRuleParser(ruleparser); }
public Func <TEntity, TType> ParserRule(RuleEngineContext.RuleEngineContext contex, string ruleExpression) { IPlaceHolderParser <TEntity> placeHolderParser = RuleExpressionParserFactory.CreatePalceHolderParser <TEntity>(); placeHolderParser.AddPlaceHolders(_placeholders); var strexpression = placeHolderParser.ParsePlaceHolder(contex, ruleExpression); try { var exprep = DynamicExpressionParser .ParseLambda <TEntity, TType>(contex.EntityContextMetadata.GetRuleParserConfig(), true, strexpression); return(exprep.Compile()); } catch (Exception ex) { throw new ExpressionParserException("AggregateFunctionParser", ruleExpression, strexpression, contex.RuleEngineId, ex); } }
public Delegate ParseGroupString(RuleEngineContext.RuleEngineContext contex, string placeHolderExpression) { IPlaceHolderParser <TEntity> placeHolderParser = RuleExpressionParserFactory.CreatePalceHolderParser <TEntity>(); placeHolderParser.AddPlaceHolders(_placeholders); string[] expressions = placeHolderExpression.Split(','); int propertyCounter = 1; PlaceHolderTextParser place = new PlaceHolderTextParser(placeHolderExpression); List <string> lstExpressions = new List <string>(); foreach (var expr in expressions) { try { string parsedExpression = placeHolderParser.ParsePlaceHolder(contex, string.Format("({0}) as Prop{1}", expr, propertyCounter)); lstExpressions.Add(parsedExpression); propertyCounter = propertyCounter + 1; } catch (System.Exception ex) { throw new ExpressionParserException("GroupKeyExpressionParser", placeHolderExpression, contex.RuleEngineId, ex); } } var inputExpression = string.Format("new ({0})", string.Join(",", lstExpressions)); try { var lamdaexpr = DynamicExpressionParser .ParseLambda(contex.EntityContextMetadata.GetRuleParserConfig(), true, typeof(TEntity), null, inputExpression); return(lamdaexpr.Compile()); } catch (Exception ex) { throw new ExpressionParserException("GroupKeyExpressionParser", placeHolderExpression, inputExpression, contex.RuleEngineId, ex); } }
public EntryCriteriaRule(RuleEngineContext.RuleEngineContext context, string rule, Func <TEntity, bool> rulefunc, string name, string description = "", bool collectDiagnostic = true) : base(context, rule, rulefunc, name, description) { this._collectDiagnostic = collectDiagnostic; }
internal static GroupChildRulesetDefaultRuleBuilder <TEntity, TKey> Create(RuleEngineContext.RuleEngineContext context, RulesetBuilder <TEntity> ruleSetBuilder, GroupRuleSetBuilder <TEntity, TKey> groupRuleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) { return(new GroupChildRulesetDefaultRuleBuilder <TEntity, TKey>(context, ruleSetBuilder, groupRuleSetBuilder, propertyparser)); }
public AggregatePropertyMetadataType(RuleEngineContext.RuleEngineContext context, string propertyName, AggregateFunction aggregateFunction, string aggregateOn, IAggregateFunctionParser <TEntity, TType> aggregateFunctionParser) : base(context, propertyName, aggregateFunction, typeof(TType), aggregateOn) { this._aggregateFunctionParser = aggregateFunctionParser; }
public CountAggregatePropertyMetadataType(RuleEngineContext.RuleEngineContext context, string propertyName, Type type, string aggregateOn, IAggregateFunctionParser <TEntity, bool> aggregateFunctionParser) : base(context, propertyName, AggregateFunction.Count, aggregateOn, aggregateFunctionParser) { Type = type; }
protected AbstractRuleBuilder(IRuleEngineContext context) { _properties = new Dictionary <PropertyRule <TEntity> .PropertyHolder, Func <TEntity, bool> >(); _tempPrpertyHolder = new List <TemporarypropertyHolder>(); _context = context as RuleEngineContext.RuleEngineContext; }
internal static DefaultRuleBuilder <TEntity> Create(RuleEngineContext.RuleEngineContext contex, RulesetBuilder <TEntity> ruleSetBuilder, IPropertyRuleExpressionParser <TEntity> propertyparser) { return(new DefaultRuleBuilder <TEntity>(contex, ruleSetBuilder, propertyparser)); }