public static PropertyExpressionVisitor Create(Type type, RuntimeConfigurator configurator,
                                                       NodeSelectorFactory nodeSelectorFactory)
        {
            Type visitorType = typeof(PropertyExpressionVisitor <>).MakeGenericType(type);

            return((PropertyExpressionVisitor)Activator.CreateInstance(visitorType, configurator, nodeSelectorFactory));
        }
 public static AddFactNode <T, TFact> AddFact <T, TFact>(this RuntimeConfigurator configurator,
                                                         Func <T, TFact> factFactory)
     where T : class
     where TFact : class
 {
     return(configurator.CreateNode(id => new AddFactNode <T, TFact>(id, factFactory)));
 }
Пример #3
0
        public static NodeSelectorFactory Create(RuntimeConfigurator configurator, NodeSelectorFactory factory,
                                                 PropertyInfo propertyInfo)
        {
            Type type = typeof(PropertyNodeSelectorFactory <>).MakeGenericType(propertyInfo.PropertyType);

            return((NodeSelectorFactory)Activator.CreateInstance(type, configurator, factory, propertyInfo));
        }
        public static PropertyExpressionVisitor Create(Type type, RuntimeConfigurator configurator,
            NodeSelectorFactory nodeSelectorFactory)
        {
            Type visitorType = typeof(PropertyExpressionVisitor<>).MakeGenericType(type);

            return (PropertyExpressionVisitor)Activator.CreateInstance(visitorType, configurator, nodeSelectorFactory);
        }
        public static NodeSelectorFactory Create(RuntimeConfigurator configurator, NodeSelectorFactory factory,
            PropertyInfo propertyInfo)
        {
            Type type = typeof(PropertyNodeSelectorFactory<>).MakeGenericType(propertyInfo.PropertyType);

            return (NodeSelectorFactory)Activator.CreateInstance(type, configurator, factory, propertyInfo);
        }
Пример #6
0
        public PropertyNodeSelector(NodeSelector next, RuntimeConfigurator configurator, PropertyInfo property)
        {
            _next         = next;
            _configurator = configurator;

            Property = property;
        }
Пример #7
0
 public JoinNodeLocator(RuntimeConfigurator runtimeConfigurator, MemoryNode <T> left, MemoryNode <T> right)
 {
     _configurator    = runtimeConfigurator;
     _left            = left;
     _matchRight      = node => MatchNode(node, right);
     _rightActivation = () => right as RightActivation <T>;
 }
Пример #8
0
        public static EqualNode <T, TProperty> Equal <T, TProperty>(this RuntimeConfigurator configurator)
            where T : class
        {
            EqualNode <T, TProperty> node = configurator.CreateNode(id => new EqualNode <T, TProperty>(id, configurator));

            return(node);
        }
 public NotEqualNodeSelectorFactory(NodeSelectorFactory nextFactory, RuntimeConfigurator configurator,
                                    TValue value)
 {
     _nextFactory  = nextFactory;
     _value        = value;
     _configurator = configurator;
 }
 public static OuterJoinNode <T1, T2> Outer <T1, T2>(this RuntimeConfigurator configurator,
                                                     RightActivation <T2> rightActivation)
     where T1 : class
     where T2 : class
 {
     return(configurator.CreateNode(id => new OuterJoinNode <T1, T2>(id, rightActivation)));
 }
Пример #11
0
 public LeftJoinNodeLocator(RuntimeConfigurator runtimeConfigurator, MemoryNode <Token <T, TDiscard> > left)
 {
     _configurator    = runtimeConfigurator;
     _left            = left;
     _matchRight      = MatchConstantNode;
     _rightActivation = _configurator.Constant <T>;
 }
Пример #12
0
        public OdoyuleRulesEngine(RuntimeConfigurator configurator)
        {
            _initializers = new GenericTypeCache <AlphaNodeInitializer>(typeof(AlphaNodeInitializerImpl <>));
            _objectCache  = new GenericTypeCache <ActivationTypeProxy>(typeof(ActivationTypeProxyImpl <>));
            _types        = new GenericTypeCache <Activation>(typeof(AlphaNode <>));

            _configurator = configurator;
        }
        public static Activation <T> Property <T, TProperty>(this RuntimeConfigurator configurator,
                                                             Expression <Func <T, TProperty> > propertyExpression)
            where T : class
        {
            PropertyInfo propertyInfo = propertyExpression.GetPropertyInfo();

            return(Property <T, TProperty>(configurator, propertyInfo));
        }
        public static NotNullNode <T, TProperty> NotNull <T, TProperty>(this RuntimeConfigurator configurator)
            where T : class
            where TProperty : class
        {
            TokenValueFactory <T, TProperty> tokenValue = Conditionals.Property <T, TProperty>();

            return(configurator.CreateNode(id => new NotNullNode <T, TProperty>(id, tokenValue)));
        }
        public static ExistsNode <T, TProperty> Exists <T, TProperty>(this RuntimeConfigurator configurator)
            where T : class
            where TProperty : class, IEnumerable
        {
            TokenValueFactory <T, TProperty> tokenValue = Conditionals.Property <T, TProperty>();

            return(configurator.CreateNode(id => new ExistsNode <T, TProperty>(id, tokenValue)));
        }
        public static PropertyNode <T, TProperty> Property <T, TProperty>(
            this RuntimeConfigurator configurator, PropertyInfo propertyInfo, Action <T, Action <TProperty> > propertyMatch)
            where T : class
        {
            PropertyNode <T, TProperty> propertyNode =
                configurator.CreateNode(id => new PropertyNode <T, TProperty>(id, propertyInfo, propertyMatch));

            return(propertyNode);
        }
Пример #17
0
        public static CompareNode <T, TProperty> Compare <T, TProperty>(this RuntimeConfigurator configurator,
                                                                        Comparator <TProperty, TProperty> comparator,
                                                                        TProperty value)
            where T : class
        {
            Value <TProperty> rightValue = Conditionals.Constant(value);

            return(Compare <T, TProperty>(configurator, comparator, rightValue));
        }
Пример #18
0
        public static CompareNode <T, TProperty> LessThanOrEqual <T, TProperty>(this RuntimeConfigurator configurator,
                                                                                TProperty value)
            where T : class
            where TProperty : IComparable <TProperty>
        {
            var comparator = new LessThanOrEqualValueComparator <TProperty>();

            return(Compare <T, TProperty>(configurator, comparator, value));
        }
Пример #19
0
        public OuterJoinNodeLocator(RuntimeConfigurator runtimeConfigurator, MemoryNode <T1> left, MemoryNode <T2> right)
        {
            _configurator    = runtimeConfigurator;
            _left            = left;
            _right           = right;
            _rightActivation = () => right as RightActivation <T2>;

            _matchRight = MatchNode;
        }
Пример #20
0
        public static CompareNode <T, TProperty> GreaterThan <T, TProperty>(this RuntimeConfigurator configurator,
                                                                            TProperty value)
            where T : class
            where TProperty : IComparable <TProperty>
        {
            var comparator = new GreaterThanValueComparator <TProperty>();

            return(Compare <T, TProperty>(configurator, comparator, value));
        }
Пример #21
0
        public static CompareNode <T, TProperty> Compare <T, TProperty>(this RuntimeConfigurator configurator,
                                                                        Comparator <TProperty, TProperty> comparator,
                                                                        Value <TProperty> value)
            where T : class
        {
            TokenValueFactory <T, TProperty> tokenValue = Conditionals.Property <T, TProperty>();

            return(configurator.CreateNode(id => new CompareNode <T, TProperty>(id, tokenValue, comparator, value)));
        }
        public static EachNode <T, TProperty, TElement> Each <T, TProperty, TElement>(
            this RuntimeConfigurator configurator,
            Action <TProperty, Action <TElement, int> > elementMatch)
            where T : class
            where TProperty : class, IEnumerable
        {
            TokenValueFactory <T, TProperty> tokenValue = Conditionals.Property <T, TProperty>();

            return(configurator.CreateNode(id => new EachNode <T, TProperty, TElement>(id, tokenValue, elementMatch)));
        }
 public CompareNodeSelectorFactory(NodeSelectorFactory nextFactory,
                                   RuntimeConfigurator configurator,
                                   Comparator <TValue, TValue> comparator,
                                   Value <TValue> value)
 {
     _nextFactory  = nextFactory;
     _value        = value;
     _configurator = configurator;
     _comparator   = comparator;
 }
Пример #24
0
 public CompareNodeSelector(NodeSelector next,
                            RuntimeConfigurator configurator,
                            Comparator <TProperty, TProperty> comparator,
                            Value <TProperty> value)
 {
     _value        = value;
     _next         = next;
     _configurator = configurator;
     _comparator   = comparator;
 }
        public static PropertyNode <T, TProperty, TValue> Property <T, TProperty, TValue>(
            this RuntimeConfigurator configurator, PropertyInfo propertyInfo,
            PropertySelector <TProperty, TValue> propertySelector)
            where T : class
        {
            PropertyNode <T, TProperty, TValue> propertyNode = configurator.CreateNode(
                id => new PropertyNode <T, TProperty, TValue>(id, propertyInfo, propertySelector));

            return(propertyNode);
        }
Пример #26
0
        public RulesEngine Build()
        {
            RuntimeConfigurator runtimeConfigurator = _runtimeConfiguratorFactory();

            RuleCompiler compiler = new OdoyuleRuleCompiler(runtimeConfigurator);

            _rules.Each(rule => compiler.Add(rule));
            compiler.Compile();

            return(runtimeConfigurator.RulesEngine);
        }
        public static PropertyNode <T, TProperty> Property <T, TProperty>(
            this RuntimeConfigurator configurator, Expression <Func <T, TProperty> > propertyExpression)
            where T : class
        {
            PropertyInfo propertyInfo = propertyExpression.GetPropertyInfo();

            PropertyNode <T, TProperty> propertyNode =
                configurator.CreateNode(id => new PropertyNode <T, TProperty>(id, propertyInfo));

            return(propertyNode);
        }
        public static CompareNode <T, TProperty> LessThanOrEqual <T, TProperty>(this RuntimeConfigurator configurator,
                                                                                TProperty value)
            where T : class
            where TProperty : IComparable <TProperty>
        {
            Value <TProperty> rightValue = Conditional.Constant(value);
            TokenValueFactory <T, TProperty> tokenValue = Conditional.Property <T, TProperty>();

            var comparator = new LessThanOrEqualValueComparator <TProperty>();

            return(configurator.CreateNode(id => new CompareNode <T, TProperty>(id, tokenValue, comparator, rightValue)));
        }
        public static Activation <T> Property <T, TProperty>(this RuntimeConfigurator configurator,
                                                             PropertyInfo propertyInfo)
            where T : class
        {
            PropertySelector propertySelector = configurator.GetPropertySelector(propertyInfo);

            Type propertyNodeType = typeof(PropertyNode <, ,>)
                                    .MakeGenericType(typeof(T), propertySelector.PropertyType, propertySelector.ValueType);

            return(configurator.CreateNode(
                       id => (Activation <T>)Activator.CreateInstance(propertyNodeType, id, propertyInfo, propertySelector)));
        }
Пример #30
0
        public RulesEngine Build()
        {
            RuntimeConfigurator runtimeConfigurator = _runtimeConfiguratorFactory();

            foreach (var configuratorAction in _runtimeConfiguratorActions)
            {
                configuratorAction(runtimeConfigurator);
            }

            CompileRules(runtimeConfigurator);

            return(runtimeConfigurator.RulesEngine);
        }
Пример #31
0
        public static NodeSelector Create(RuntimeConfigurator configurator, Type tokenType,
            NodeSelectorFactory nextSelectorFactory, object value)
        {
            Type[] arguments = tokenType.GetGenericArguments();
            if (!arguments[1].IsInstanceOfType(value))
                throw new RuntimeConfigurationException("Value type does not match token type: " + value.GetType().GetTypeName());

            Type type = typeof(EqualNodeSelector<,>)
                .MakeGenericType(arguments);

            var nodeSelector = (NodeSelector)Activator.CreateInstance(type, configurator, nextSelectorFactory, value);

            return nodeSelector;
        }
Пример #32
0
        public static NodeSelector Create <T, TProperty>(RuntimeConfigurator configurator,
                                                         NodeSelectorFactory nextSelectorFactory,
                                                         PropertyInfo propertyInfo)
        {
            PropertySelector propertySelector = configurator.GetPropertySelector(propertyInfo);

            Type type = typeof(PropertyNodeSelector <, ,>)
                        .MakeGenericType(typeof(T), propertySelector.PropertyType, propertySelector.ValueType);

            var nodeSelector =
                (NodeSelector)
                Activator.CreateInstance(type, configurator, nextSelectorFactory, propertyInfo, propertySelector);

            return(nodeSelector);
        }
        public static ConditionNode <Token <T1, T2> > Condition <T1, T2>(
            this RuntimeConfigurator configurator, Predicate <T2> condition)
            where T1 : class
        {
            ConditionNode <Token <T1, T2> > conditionNode = configurator.CreateNode(
                id => new ConditionNode <Token <T1, T2> >(id, (value, next) =>
            {
                if (condition(value.Item2))
                {
                    next();
                }
            }));

            return(conditionNode);
        }
 protected PropertyExpressionVisitor(RuntimeConfigurator runtimeConfigurator)
 {
     Configurator = runtimeConfigurator;
 }
        void CompileRules(RuntimeConfigurator runtimeConfigurator)
        {
            RuleCompiler compiler = new OdoyuleRuleCompiler(runtimeConfigurator);

            _rules.Each(compiler.Compile);
        }
 public OdoyuleRuleCompiler(RuntimeConfigurator configurator)
 {
     _configurator = configurator;
 }
Пример #37
0
 public OdoyuleRuleCompiler(RuntimeConfigurator configurator)
 {
     _configurator = configurator;
     _rules = new DictionaryCache<string, Rule>(rule => rule.RuleName);
 }