public ConditionalRuleBuilder(IRule rule, ParameterExpression parameterExpression) { _valueOrLeftNode = rule.LeftNode; _ruleOperator = rule.Operator; _valueOrRightNode = rule.RightNode; _parameterExpression = parameterExpression; }
private ExpressionType _GetExpressionFromOperatorEnumerate(RuleOperator ruleOperator) { const ExpressionType expressionType = new ExpressionType(); var fieldInfo = expressionType.GetType().GetField(Enum.GetName(typeof(RuleOperator), ruleOperator)); return((ExpressionType)fieldInfo.GetValue(ruleOperator)); }
public IRule Create(RuleOperator ruleOperator, object leftNode = null, object rightNode = null) { var ruleTypes = _SearchRuleTypes(_GetAssembly()); var ruleToCreate = _GetRule(ruleOperator, ruleTypes); var instanceOfRuleType = _CreateInstanceOfRuleType(ruleToCreate, leftNode, rightNode); return(instanceOfRuleType); }
public Rule(RuleOperator ruleOperator, NormOperator normOperator, Tuple <Variable, FuzzySet> outputSet, Dictionary <Variable, FuzzySet> inputSet) { RuleOperator = ruleOperator; NormOperator = normOperator; OutputSet = outputSet; InputSet = inputSet; Valid = true; }
public TotalCondition(string userCol, string totalCol, RuleOperator op, float arg) { this.userCol = userCol; this.totalCol = totalCol; this.op = op; this.arg = arg; this.lookup = new Dictionary <string, float>(); }
public override string ToString() { string returnVal = "IF "; var statements = InputSet.Select(x => x.Key.Name + " = " + x.Value.Name).ToList(); statements.ForEach(x => x += RuleOperator.GetName(typeof(RuleOperator), RuleOperator)); returnVal += (" THEN " + OutputSet.Item1.Name + " = " + OutputSet.Item2.Name); return(returnVal); }
public override string ToString() { string returnVal = "IF "; var statements = VariableFunction.Select(x => x.Key.VariableName + " = " + x.Value.SetName).ToList(); statements.ForEach(x => returnVal += " " + x + " " + RuleOperator.GetName(typeof(RuleOperator), RuleOperator)); returnVal = returnVal.Substring(0, returnVal.Length - 3); returnVal += (" THEN " + OuputVariableFunction.Item1.VariableName + " = " + OuputVariableFunction.Item2.SetName); return(returnVal); }
protected virtual List <Customer> ExecuteQuery <TValue>(RuleOperator op, Expression <Func <Customer, TValue> > left, object right) { var paramExpr = Expression.Parameter(typeof(Customer), "it"); var valueExpr = ExpressionHelper.CreateValueExpression(left.Body.Type, right); // Expression.Constant(right) var expr = op.GetExpression(left.Body, valueExpr, true); var predicate = ExpressionHelper.CreateLambdaExpression(paramExpr, expr); var result = _customers.AsQueryable().Where(predicate).Cast <Customer>().ToList(); return(result); }
private bool CheckRuleConditions(RuleOperator ruleOp, List <Object> conditions) { bool conditionMet = true; IList <Object> retreivedFacts = new List <Object>(); foreach (Object clause in conditions) { conditionMet = conditionMet & EvaluateClause(clause, retreivedFacts); } return(conditionMet); }
public ArchitecturalRule(string origin, string target, RuleOperator ruleOperator, params RelationType[] types) : base() { OriginLayer = origin; TargetLayer = target; RuleOperator = ruleOperator; if (types != null && types.Any()) { RelationTypes = types.ToList(); } }
private Type _GetRule(RuleOperator ruleOperator, IEnumerable <Type> ruleTypes) { var ruleToCreate = (from ruleTypeToCreate in ruleTypes let memberInfo = ruleTypeToCreate let customAttribute = memberInfo.GetCustomAttributes(typeof(RuleOperatorAttribute), true).FirstOrDefault() let attributeToCheck = customAttribute as RuleOperatorAttribute where attributeToCheck != null && attributeToCheck.RuleOperator.Equals(ruleOperator) select ruleTypeToCreate).FirstOrDefault(); return(ruleToCreate); }
/// <summary> /// Создание нового экземпляра инструкции компилятору. /// </summary> /// <param name="Source">Источник, кто добавил в компилятор запись.</param> /// <param name="Helper">Дополнительная информация о результатах парсера.</param> public ParserToken(Nonterminal Source, RuleOperator CurrentRule, int Helper = int.MinValue, ulong Id = ulong.MaxValue) { this.Source = Source; this.CurrentRule = CurrentRule; this.Helper = Helper; if (Id != ulong.MaxValue) { this.Id = Id; } else { this.Id = ran.NextULong(); } }
/// <summary> /// Preformats the operator in the token according to the rule /// </summary> /// <param name="token">The token.</param> /// <returns></returns> private string PreFormatOperator(Rule currentRule, string token) { string op = RawToken(token); if (Rules.ContainsOperator(op)) { RuleOperator ruleOp = Rules.Operators[op]; //spaces if (ruleOp.SpaceBefore) { op = string.Format(" {0}", op); } if (ruleOp.SpaceAfter) { op = string.Format("{0} ", op); } //newlines if (ruleOp.NewLine == NewLineType.LeftIndent && currentRule.Display == DisplayType.Block) { op = string.Format("{0}\r\n{1}", FormatRules.LEFTINDENT, op); } else if (ruleOp.NewLine == NewLineType.RightIndent && currentRule.Display == DisplayType.Block) { op = string.Format("{0}{1}\r\n", op, FormatRules.RIGHTINDENT); } else if (ruleOp.NewLine == NewLineType.Inline && currentRule.Display == DisplayType.Block) { op = string.Format("{0}\r\n", op); } } //add the formatted op back to the token string[] subTokens = Regex.Split(token, string.Format("({0})", FormatRules.ControlRegex.ToString())); StringBuilder tokenBuilder = new StringBuilder(); for (int i = 0; i < subTokens.Length; i++) { if (subTokens[i] == RawToken(token)) { subTokens[i] = op; } tokenBuilder.Append(subTokens[i]); } return(tokenBuilder.ToString()); }
public override Expression GetExpression(RuleOperator op, Expression valueExpression, bool liftToNull) { var ruleSetId = ((ConstantExpression)valueExpression).Value.Convert <int>(); // Get other expression group _ruleVisitor.TryGetTarget(out var visitor); var otherGroup = _ruleFactory.CreateExpressionGroup(ruleSetId, visitor) as FilterExpressionGroup; var otherPredicate = otherGroup?.ToPredicate(liftToNull); if (otherPredicate is Expression <Func <Customer, bool> > lambda) { MemberExpression = lambda; } return(base.GetExpression(op, Expression.Constant(true), liftToNull)); }
public static bool ApplyOperator(float lhs, RuleOperator op, float rhs) { switch (op) { case RuleOperator.lt: return(lhs < rhs); case RuleOperator.lte: return(lhs <= rhs); case RuleOperator.gt: return(lhs > rhs); case RuleOperator.gte: return(lhs >= rhs); default: return(lhs == rhs); } }
public static string OperatorToString(RuleOperator op) { switch (op) { case RuleOperator.lt: return("<"); case RuleOperator.lte: return("<="); case RuleOperator.gt: return(">"); case RuleOperator.gte: return(">="); default: return("="); } }
public override Expression GetExpression(RuleOperator op, Expression valueExpression, bool liftToNull) { // Create the Any()/All() lambda predicate (the part within parentheses) var predicate = ExpressionHelper.CreateLambdaExpression( Expression.Parameter(typeof(TPredicate), "it2"), op.GetExpression(PredicateExpression.Body, valueExpression, liftToNull)); var body = Expression.Call( typeof(Enumerable), MethodName, // .Any/All<TPredicate>() new[] { typeof(TPredicate) }, // 0 = left collection path: x.Orders.selectMany(o => o.OrderItems) // 1 = right Any/All predicate: y => y.ProductId = 1 new Expression[] { MemberExpression.Body, predicate }); return(body); }
/// <summary> /// Создание экземпляра нетерминала. /// </summary> /// <param name="rule">Указывает, какая реакция должна быть на истинность всех терминалов и нетерминалов.</param> /// <param name="terminalsOrNonterminals">Список терминалов и нетерминалов.</param> public Nonterminal(RuleOperator rule, params object[] terminalsOrNonterminals) { this.rule = rule; AddRange(terminalsOrNonterminals ?? throw new ArgumentNullException(nameof(terminalsOrNonterminals))); }
protected override IEnumerable <RuleDescriptor> LoadDescriptors() { var stores = _services.StoreService.GetAllStores() .Select(x => new RuleValueSelectListOption { Value = x.Id.ToString(), Text = x.Name }) .ToArray(); var listComparingOperators = new RuleOperator[] { RuleOperator.In, RuleOperator.NotIn, RuleOperator.AllIn, RuleOperator.NotAllIn, RuleOperator.Contains, RuleOperator.NotContains, RuleOperator.IsEqualTo, RuleOperator.IsNotEqualTo }; var descriptors = new List <CartRuleDescriptor> { new CartRuleDescriptor { Name = "Currency", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.Currency"), RuleType = RuleType.IntArray, ProcessorType = typeof(CurrencyRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("Currency") { Multiple = true } }, new CartRuleDescriptor { Name = "Language", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.Language"), RuleType = RuleType.IntArray, ProcessorType = typeof(LanguageRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("Language") { Multiple = true } }, new CartRuleDescriptor { Name = "Store", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.Store"), RuleType = RuleType.IntArray, ProcessorType = typeof(StoreRule), Constraints = new IRuleConstraint[0], SelectList = new LocalRuleValueSelectList(stores) { Multiple = true } }, new CartRuleDescriptor { Name = "IPCountry", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.IPCountry"), RuleType = RuleType.StringArray, ProcessorType = typeof(IPCountryRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("Country") { Multiple = true } }, new CartRuleDescriptor { Name = "CustomerRole", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.IsInCustomerRole"), RuleType = RuleType.IntArray, ProcessorType = typeof(CustomerRoleRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("CustomerRole") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "CartTotal", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.CartTotal"), RuleType = RuleType.Money, Constraints = new IRuleConstraint[0], ProcessorType = typeof(CartTotalRule) }, new CartRuleDescriptor { Name = "CartSubtotal", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.CartSubtotal"), RuleType = RuleType.Money, Constraints = new IRuleConstraint[0], ProcessorType = typeof(CartSubtotalRule) }, new CartRuleDescriptor { Name = "ProductInCart", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.ProductInCart"), RuleType = RuleType.IntArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(ProductInCartRule), SelectList = new RemoteRuleValueSelectList("Product") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "ProductInWishlist", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.ProductOnWishlist"), RuleType = RuleType.IntArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(ProductOnWishlistRule), SelectList = new RemoteRuleValueSelectList("Product") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "ProductReviewCount", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.ProductReviewCount"), RuleType = RuleType.Int, Constraints = new IRuleConstraint[0], ProcessorType = typeof(ProductReviewCountRule) }, new CartRuleDescriptor { Name = "RewardPointsBalance", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.RewardPointsBalance"), RuleType = RuleType.Int, Constraints = new IRuleConstraint[0], ProcessorType = typeof(RewardPointsBalanceRule) }, new CartRuleDescriptor { Name = "CartBillingCountry", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.BillingCountry"), RuleType = RuleType.IntArray, ProcessorType = typeof(BillingCountryRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("Country") { Multiple = true } }, new CartRuleDescriptor { Name = "CartShippingCountry", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.ShippingCountry"), RuleType = RuleType.IntArray, ProcessorType = typeof(ShippingCountryRule), Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("Country") { Multiple = true } }, new CartRuleDescriptor { Name = "CartShippingMethod", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.ShippingMethod"), RuleType = RuleType.IntArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(ShippingMethodRule), SelectList = new RemoteRuleValueSelectList("ShippingMethod") { Multiple = true } }, new CartRuleDescriptor { Name = "CartOrderCount", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.OrderCount"), RuleType = RuleType.Int, Constraints = new IRuleConstraint[0], ProcessorType = typeof(OrderCountRule) }, new CartRuleDescriptor { Name = "CartSpentAmount", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.SpentAmount"), RuleType = RuleType.Money, Constraints = new IRuleConstraint[0], ProcessorType = typeof(SpentAmountRule) }, new CartRuleDescriptor { Name = "CartPurchasedProduct", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.PurchasedProduct"), RuleType = RuleType.IntArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(PurchasedProductRule), SelectList = new RemoteRuleValueSelectList("Product") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "CartPurchasedFromManufacturer", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.PurchasedFromManufacturer"), RuleType = RuleType.IntArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(PurchasedFromManufacturerRule), SelectList = new RemoteRuleValueSelectList("Manufacturer") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "CartPaymentMethod", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.PaymentMethod"), RuleType = RuleType.StringArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(PaymentMethodRule), SelectList = new RemoteRuleValueSelectList("PaymentMethod") { Multiple = true } }, new CartRuleDescriptor { Name = "CartPaidBy", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.PaidBy"), RuleType = RuleType.StringArray, Constraints = new IRuleConstraint[0], ProcessorType = typeof(PaidByRule), SelectList = new RemoteRuleValueSelectList("PaymentMethod") { Multiple = true }, Operators = listComparingOperators }, new CartRuleDescriptor { Name = "RuleSet", DisplayName = _services.Localization.GetResource("Admin.Rules.FilterDescriptor.RuleSet"), RuleType = RuleType.Int, ProcessorType = typeof(RuleSetRule), Operators = new[] { RuleOperator.IsEqualTo, RuleOperator.IsNotEqualTo }, Constraints = new IRuleConstraint[0], SelectList = new RemoteRuleValueSelectList("CartRule"), } }; descriptors .Where(x => x.RuleType == RuleType.Money) .Each(x => x.Metadata["postfix"] = _services.StoreContext.CurrentStore.PrimaryStoreCurrency.CurrencyCode); return(descriptors); }
public virtual Expression GetExpression(RuleOperator op, Expression valueExpression, bool liftToNull) { return(op.GetExpression(MemberExpression.Body, valueExpression, liftToNull)); }
public RuleOperatorAttribute(RuleOperator ruleOperator) { RuleOperator = ruleOperator; }
/// <summary> /// Создание экземпляра нетерминала. /// </summary> /// <param name="Name">Устанавливает имя терминала.</param> /// <param name="rule">Указывает, какая реакция должна быть на истинность всех терминалов и нетерминалов.</param> /// <param name="terminalsOrNonterminals">Список терминалов и нетерминалов.</param> public Nonterminal(string Name, RuleOperator rule, params object[] terminalsOrNonterminals) : this(rule, terminalsOrNonterminals) { this.Name = Name; }
public ColumnCondition(string colName, RuleOperator op, float arg) { this.op = op; this.arg = arg; this.colName = colName; }
} // ONLY if MyOperator is Convert. // Constructor public TextRule(TileType _mySubject, RuleOperator _myOperator, TileType _typeToConvertTo = TileType.Undefined) { this.MySubject = _mySubject; this.MyOperator = _myOperator; this.TypeToConvertTo = _typeToConvertTo; }
// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public TextBlock(Board _boardRef, TextBlockData _data) { base.InitializeAsTile(_boardRef, _data); this.MyType = _data.MyType; this.MySubjectType = _data.MySubjectType; // Infer MyTextLoc and MySubject from my type! switch (MySubjectType) { // Start case TileType.Abba: case TileType.Brick: case TileType.Crate: case TileType.Star: this.MyTextLoc = TextLoc.Start; break; //case TileType.Abba: // this.MyTextLoc = TextLoc.Start; // this.MySubject = TileType.Abba; // break; //case TileType.Crate: //this.MyTextLoc = TextLoc.Start; //this.MySubject = TileType.Crate; //break; // Middle case TileType.Is: this.MyTextLoc = TextLoc.Middle; break; // End case TileType.Destroys: MyOperator = RuleOperator.IsDestroys; this.MyTextLoc = TextLoc.End; break; case TileType.OverlapGoal: MyOperator = RuleOperator.IsOverlapGoal; this.MyTextLoc = TextLoc.End; break; case TileType.Push: MyOperator = RuleOperator.IsPush; this.MyTextLoc = TextLoc.End; break; case TileType.Stop: MyOperator = RuleOperator.IsStop; this.MyTextLoc = TextLoc.End; break; case TileType.You: MyOperator = RuleOperator.IsYou; this.MyTextLoc = TextLoc.End; break; // TESTING If-Else case TileType.If: case TileType.Else: case TileType.Then: case TileType.Not: case TileType.And: case TileType.Or: case TileType.True: case TileType.False: case TileType.Win: case TileType.Lose: case TileType.X: case TileType.Y: case TileType.Z: MyOperator = RuleOperator.Undefined; this.MyTextLoc = TextLoc.Undefined; break; default: Debug.LogError("Oops, TextBlock doesn't have case handled for type: " + MySubjectType); break; } }
public static bool ApplyOperator(float lhs, RuleOperator op, float rhs) { switch (op) { case RuleOperator.lt: return lhs < rhs; case RuleOperator.lte: return lhs <= rhs; case RuleOperator.gt: return lhs > rhs; case RuleOperator.gte: return lhs >= rhs; default: return lhs == rhs; } }
public TotalCondition(string userCol, string totalCol, RuleOperator op, float arg) { this.userCol = userCol; this.totalCol = totalCol; this.op = op; this.arg = arg; this.lookup = new Dictionary<string, float>(); }
public static string OperatorToString(RuleOperator op) { switch (op) { case RuleOperator.lt: return "<"; case RuleOperator.lte: return "<="; case RuleOperator.gt: return ">"; case RuleOperator.gte: return ">="; default: return "="; } }
public Rule(RuleProperty property, RuleOperator operation, object value) { Property = property; Operator = operation; Value = value; }
public RuleOperatorCuLeRule(CuLeRule i_CuLeRule_A, CuLeRule i_CuLeRule_B, RuleOperator i_RuleOperator) { m_CuLeRule_A = i_CuLeRule_A; m_CuLeRule_B = i_CuLeRule_B; m_RuleOperator = i_RuleOperator; }
public RuleLine(RuleOperator ruleOperator, Dictionary <VariableLine, MemberFunction> variableFunction, Tuple <VariableLine, MemberFunction> ouputVariableFunction) { RuleOperator = ruleOperator; VariableFunction = variableFunction; OuputVariableFunction = ouputVariableFunction; }
/// <summary> /// Создание экземпляра нетерминала. /// </summary> /// <param name="Name">Устанавливает имя терминала.</param> /// <param name="TransferToStackCode">Функция преобразования жетонов в стек-код.</param> /// <param name="rule">Указывает, какая реакция должна быть на истинность всех терминалов и нетерминалов.</param> /// <param name="terminalsOrNonterminals">Список терминалов и нетерминалов.</param> public Nonterminal(string Name, TransferToStackCode TransferToStackCode, RuleOperator rule, params object[] terminalsOrNonterminals) : this(Name, rule, terminalsOrNonterminals) { this.TransferToStackCode = TransferToStackCode; }