예제 #1
0
 public void Should_Verify_Or()
 {
     Assert.True(LogicalOperators.Or(true, true));
     Assert.True(LogicalOperators.Or(false, true));
     Assert.True(LogicalOperators.Or(true, false));
     Assert.False(LogicalOperators.Or(false, false));
 }
예제 #2
0
 public SliceByDimensionMembers(T dimensionKey, LogicalOperators loperator, params T[] values)
 {
     _values    = new List <T>();
     _dimension = dimensionKey;
     _operator  = loperator;
     _values.AddRange(values);
 }
예제 #3
0
        public void Init_GivenSetupWithIntegerValue_ReturnsSettedValues()
        {
            // Arrange
            ConditionType    expectedConditionType   = ConditionType.IsoCountryCode;
            Operators        expectedOperator        = Operators.NotEqual;
            int              expectedOperand         = 1616;
            LogicalOperators expectedLogicalOperator = LogicalOperators.Eval;
            DataTypes        expectedDataType        = DataTypes.Integer;

            IntegerConditionNode <ConditionType> sut = new IntegerConditionNode <ConditionType>(expectedConditionType, expectedOperator, expectedOperand);

            // Act
            ConditionType    actualConditionType   = sut.ConditionType;
            Operators        actualOperator        = sut.Operator;
            DataTypes        actualDataType        = sut.DataType;
            LogicalOperators actualLogicalOperator = sut.LogicalOperator;
            int actualOperand = sut.Operand;

            // Assert
            actualConditionType.Should().Be(expectedConditionType);
            actualOperator.Should().Be(expectedOperator);
            actualOperand.Should().Be(expectedOperand);
            actualLogicalOperator.Should().Be(expectedLogicalOperator);
            actualDataType.Should().Be(expectedDataType);
        }
예제 #4
0
        public PermissionsAuthorizationAttribute(LogicalOperators logicalOperator, params string[] allowedPermissions)
        {
            _allowedPermissions = allowedPermissions;
            _logicalOperator    = logicalOperator;

            Permissions = new PermissionsRequirement(_logicalOperator, _allowedPermissions);
        }
        internal DimensionSlicerBuilder <T> SetOperationSegments(LogicalOperators loperator, params T[] memberKeys)
        {
            _operator = loperator;
            _members.AddRange(memberKeys);

            return(this);
        }
        internal ConditionNodeDataModel <TConditionType> CreateConditionNodeDataModel <TConditionType>(dynamic conditionNode)
        {
            LogicalOperators logicalOperator = this.Parse <LogicalOperators>((string)conditionNode.LogicalOperator);

            if (logicalOperator == LogicalOperators.Eval)
            {
                return(new ValueConditionNodeDataModel <TConditionType>
                {
                    ConditionType = this.Parse <TConditionType>((string)conditionNode.ConditionType),
                    DataType = this.Parse <DataTypes>((string)conditionNode.DataType),
                    LogicalOperator = logicalOperator,
                    Operator = this.Parse <Operators>((string)conditionNode.Operator),
                    Operand = (string)conditionNode.Operand
                });
            }
            else
            {
                IEnumerable <dynamic> childConditionNodes = conditionNode.ChildConditionNodes as IEnumerable <dynamic>;

                List <ConditionNodeDataModel <TConditionType> > conditionNodeDataModels = new List <ConditionNodeDataModel <TConditionType> >(childConditionNodes.Count());
                foreach (dynamic child in childConditionNodes)
                {
                    conditionNodeDataModels.Add(this.CreateConditionNodeDataModel <TConditionType>(child));
                }

                return(new ComposedConditionNodeDataModel <TConditionType>
                {
                    ChildConditionNodes = conditionNodeDataModels,
                    LogicalOperator = logicalOperator
                });
            }
        }
예제 #7
0
        public string FormatOperator(LogicalOperators type)
        {
            switch (type)
            {
            case LogicalOperators.NotDefined:
                break;

            case LogicalOperators.Exists:
                return("exists");

            case LogicalOperators.Eq:
                return("=");

            case LogicalOperators.Lte:
                return("&#8804;");

            case LogicalOperators.Gte:
                return("&#8805;");

            case LogicalOperators.Between:
                return("is between");

            default:
                break;
            }
            return("");
        }
예제 #8
0
        public void Init_GivenSetupWithStringValue_ReturnsSettedValues()
        {
            // Arrange
            ConditionType    expectedConditionType   = ConditionType.IsoCountryCode;
            Operators        expectedOperator        = Operators.NotEqual;
            string           expectedOperand         = "Such operand, much wow.";
            LogicalOperators expectedLogicalOperator = LogicalOperators.Eval;
            DataTypes        expectedDataType        = DataTypes.String;

            StringConditionNode <ConditionType> sut = new StringConditionNode <ConditionType>(expectedConditionType, expectedOperator, expectedOperand);

            // Act
            ConditionType    actualConditionType   = sut.ConditionType;
            Operators        actualOperator        = sut.Operator;
            DataTypes        actualDataType        = sut.DataType;
            LogicalOperators actualLogicalOperator = sut.LogicalOperator;
            string           actualOperand         = sut.Operand;

            // Assert
            actualConditionType.Should().Be(expectedConditionType);
            actualOperator.Should().Be(expectedOperator);
            actualOperand.Should().Be(expectedOperand);
            actualLogicalOperator.Should().Be(expectedLogicalOperator);
            actualDataType.Should().Be(expectedDataType);
        }
        public void Init_GivenSetupWithDecimalValue_ReturnsSettedValues()
        {
            // Arrange
            ConditionType    expectedConditionType   = ConditionType.PluviosityRate;
            Operators        expectedOperator        = Operators.NotEqual;
            decimal          expectedOperand         = 5682.2654m;
            LogicalOperators expectedLogicalOperator = LogicalOperators.Eval;
            DataTypes        expectedDataType        = DataTypes.Decimal;

            DecimalConditionNode <ConditionType> sut = new DecimalConditionNode <ConditionType>(expectedConditionType, expectedOperator, expectedOperand);

            // Act
            ConditionType    actualConditionType   = sut.ConditionType;
            Operators        actualOperator        = sut.Operator;
            DataTypes        actualDataType        = sut.DataType;
            LogicalOperators actualLogicalOperator = sut.LogicalOperator;
            decimal          actualOperand         = sut.Operand;

            // Assert
            actualConditionType.Should().Be(expectedConditionType);
            actualOperator.Should().Be(expectedOperator);
            actualOperand.Should().Be(expectedOperand);
            actualLogicalOperator.Should().Be(expectedLogicalOperator);
            actualDataType.Should().Be(expectedDataType);
        }
예제 #10
0
 public SliceByMeasure(T measureKey, Type measureType,
                       LogicalOperators loperator, object value)
 {
     _measure     = measureKey;
     _operator    = loperator;
     _measureType = measureType;
     _value       = value;
 }
예제 #11
0
 public JoinColumnMap(JoinColumn leftColumn, JoinColumn rightColumn,
                      RelationalOperators relationalOperator = RelationalOperators.Equal,
                      LogicalOperators logicalOperator       = LogicalOperators.And)
 {
     LeftColumn         = leftColumn ?? throw new ArgumentNullException(nameof(leftColumn));
     RightColumn        = rightColumn ?? throw new ArgumentNullException(nameof(rightColumn));
     RelationalOperator = relationalOperator;
     LogicalOperator    = logicalOperator;
 }
        internal DimensionSlicerBuilder <T> SetOperationSegments(LogicalOperators loperator, params string[] members)
        {
            _operator = loperator;

            foreach (var item in members)
            {
                _members.Add(_resolver.GetDimensionMember(_dimension, item));
            }

            return(this);
        }
예제 #13
0
        public void AddJoinColumn(
            IEntityName leftTable,
            IItemName leftColumnName,
            IItemName rightColumnName,
            RelationalOperators relationalOperator = RelationalOperators.Equal,
            LogicalOperators logicalOperator       = LogicalOperators.And)
        {
            var leftColumn = new JoinColumn(leftTable, leftColumnName);

            AddJoinColumn(leftColumn, GetJoinColumn(rightColumnName), relationalOperator, logicalOperator);
        }
예제 #14
0
        internal MeasureSlicerBuilder <T> SetOperationValuePair(LogicalOperators loperator, object value)
        {
            if (!value.CompatibleType(_valueType))
            {
                throw new Exception($"Attempting to make operation with incompatible value type on Measure {_measureName}.");
            }

            _operator = loperator;
            _value    = value;

            return(this);
        }
예제 #15
0
        public ODataFilter <T> AddFilter(string filter, LogicalOperators logicalOperator)
        {
            var logicalOperatorName = Enum.GetName(typeof(LogicalOperators), logicalOperator).ToLower();

            var prefix = !string.IsNullOrWhiteSpace(_value) ?
                         $" {logicalOperatorName} " :
                         $"";

            _value += prefix + $"({filter})";

            return(this);
        }
예제 #16
0
        /// <summary>
        /// Преобразовать логический оператор в строку
        /// </summary>
        private string OperToString(LogicalOperators oper)
        {
            switch (oper)
            {
            case LogicalOperators.And:
                return(Localization.UseRussian ? " И " : " And ");

            case LogicalOperators.Or:
                return(Localization.UseRussian ? " Или " : " Or ");

            default:     // LogicalOperators.None
                return("");
            }
        }
예제 #17
0
            private string GetLogicalOperator(LogicalOperators Operator)
            {
                switch (Operator)
                {
                case LogicalOperators.And:
                    return("and");

                case LogicalOperators.Or:
                    return("or");

                case LogicalOperators.Not:
                    return("not");

                default:
                    return(string.Empty);
                }
            }
        public PropertyConditionModel()
        {
            UniqueID = Guid.NewGuid().ToString("N");
            Units    = new List <UnitModel>();

            LogicalOperators = new List <LogicalOperator>();
            LogicalOperators.Add(new LogicalOperator()
            {
                Name = "<=", Id = ElsevierMaterials.Models.LogicalOperators.Lte
            });
            LogicalOperators.Add(new LogicalOperator()
            {
                Name = ">=", Id = ElsevierMaterials.Models.LogicalOperators.Gte
            });
            LogicalOperators.Add(new LogicalOperator()
            {
                Name = "is between", Id = ElsevierMaterials.Models.LogicalOperators.Between
            });
            SelectedLogical = ElsevierMaterials.Models.LogicalOperators.Between;
        }
        public void ComposedConditionNode_Init_GivenSetupWithChildConditionsAndLogicalOperator_ReturnsSettedValues()
        {
            // Arrange
            LogicalOperators expectedLogicalOperator = LogicalOperators.Eval;
            IEnumerable <IConditionNode <ConditionType> > expectedChildConditionNodes = new IConditionNode <ConditionType>[]
            {
                new Mock <IConditionNode <ConditionType> >().Object,
                new Mock <IConditionNode <ConditionType> >().Object
            };

            ComposedConditionNode <ConditionType> sut = new ComposedConditionNode <ConditionType>(expectedLogicalOperator, expectedChildConditionNodes);

            // Act
            LogicalOperators actualLogicalOperator = sut.LogicalOperator;
            IEnumerable <IConditionNode <ConditionType> > actualChildConditionNodes = sut.ChildConditionNodes;

            // Assert
            actualLogicalOperator.Should().Be(expectedLogicalOperator);
            actualChildConditionNodes.Should().NotBeNull().And.BeSameAs(expectedChildConditionNodes);
        }
예제 #20
0
 /// <summary>
 /// Initializes filter builder
 /// </summary>
 /// <param name="logicalOperator">Logical operation for expressions (default: and)</param>
 public FilterBuilder(LogicalOperators logicalOperator = LogicalOperators.And)
 {
     _filter = new Filter {
         LogicalOperator = logicalOperator
     };
 }
예제 #21
0
 public void AddStatement(Statement statement, LogicalOperators logicalOperator)
 {
     _statementAndLogicalOperators.Add(statement, logicalOperator);
 }
예제 #22
0
        public static Expression <Func <T, bool> > GetExpression <T>(IList <ExpressionFilter> filters, LogicalOperators logicalOperator)
        {
            if (filters.Count == 0)
            {
                return(null);
            }

            ParameterExpression param = Expression.Parameter(typeof(T), "t");
            Expression          exp   = null;

            while (filters.Count > 0)
            {
                var f1        = filters[0];
                var nullCheck = new ExpressionFilter
                {
                    PropertyName = f1.PropertyName,
                    Operation    = Operations.NotEqual,
                    Value        = null
                };

                if (exp == null)
                {
                    exp = GetExpression <T>(param, nullCheck, filters[0], LogicalOperators.AndAlso);
                }
                else
                {
                    switch (logicalOperator)
                    {
                    case LogicalOperators.And:
                        exp = Expression.And(exp, GetExpression <T>(param, nullCheck, filters[0], LogicalOperators.AndAlso));
                        break;

                    case LogicalOperators.Or:
                        exp = Expression.Or(exp, GetExpression <T>(param, nullCheck, filters[0], LogicalOperators.AndAlso));
                        break;

                    case LogicalOperators.OrElse:
                        exp = Expression.OrElse(exp, GetExpression <T>(param, nullCheck, filters[0], LogicalOperators.AndAlso));
                        break;

                    case LogicalOperators.AndAlso:
                    default:
                        exp = Expression.AndAlso(exp, GetExpression <T>(param, nullCheck, filters[0], LogicalOperators.AndAlso));
                        break;
                    }
                }

                filters.Remove(f1);
            }

            return(Expression.Lambda <Func <T, bool> >(exp, param));
        }
예제 #23
0
        public IComposedConditionNodeBuilder <TConditionType> WithLogicalOperator(LogicalOperators logicalOperator)
        {
            this.logicalOperator = logicalOperator;

            return(this);
        }
예제 #24
0
        private static BinaryExpression GetExpression <T>
            (ParameterExpression param, ExpressionFilter filter1, ExpressionFilter filter2, LogicalOperators logicalOperator)
        {
            Expression bin1 = GetExpression <T>(param, filter1);
            Expression bin2 = GetExpression <T>(param, filter2);

            switch (logicalOperator)
            {
            case LogicalOperators.And:
                return(Expression.And(bin1, bin2));

            case LogicalOperators.Or:
                return(Expression.Or(bin1, bin2));

            case LogicalOperators.OrElse:
                return(Expression.OrElse(bin1, bin2));

            case LogicalOperators.AndAlso:
            default:
                return(Expression.AndAlso(bin1, bin2));
            }
        }
예제 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterDescriptor"/> class.
 /// </summary>
 /// <param name="logicalOperator">The logical operator.</param>
 /// <param name="filterDescriptors">The filter descriptors.</param>
 public FilterDescriptor(LogicalOperators logicalOperator, IList<IFilterDescriptor> filterDescriptors )
 {
     LogicalOperator = logicalOperator;
     FilterDescriptors = filterDescriptors;
 }
예제 #26
0
 public static string ToSqlString(this LogicalOperators relationalOperator)
 {
     return(relationalOperator.ToString().ToLowerInvariant());
 }
예제 #27
0
 public ValidateAttribute(LogicalOperators op, params object[] values)
 {
     Op    = op;
     Value = values ?? new[] { (object)null };
 }
예제 #28
0
 public ValidateAttribute(LogicalOperators op, object value)
 {
     Op = op;
     Value = new [] {value};
 }
예제 #29
0
 public ValidateAttribute(LogicalOperators op, object value)
 {
     Op    = op;
     Value = new [] { value };
 }
예제 #30
0
 /// <summary> 
 /// Erforderliche Methode für die Designerunterstützung. 
 /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     this._grid = new GridExtensions.ExtendedDataGrid();
     this._extender = new GridExtensions.DataGridFilterExtender(this.components);
     ((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this._extender)).BeginInit();
     this.SuspendLayout();
     //
     // _grid
     //
     this._grid.AutoCreateTableStyles = false;
     this._grid.DataMember = "";
     this._grid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
     this._grid.Location = new System.Drawing.Point(0, 24);
     this._grid.Name = "_grid";
     this._grid.Size = new System.Drawing.Size(496, 352);
     this._grid.TabIndex = 0;
     this._grid.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
     this._grid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnKeyDown);
     this._grid.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
     this._grid.MouseEnter += new System.EventHandler(this.OnMouseEnter);
     this._grid.MouseHover += new System.EventHandler(this.OnMouseHover);
     this._grid.MouseLeave += new System.EventHandler(this.OnMouseLeave);
     this._grid.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnKeyUp);
     this._grid.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
     this._grid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnKeyPress);
     this._grid.DoubleClick += new EventHandler(this.OnDoubleClick);
     //
     // _extender
     //
     this._extender.AutoAdjustGridPosition = false;
     this._extender.ConsoleErrorMode = GridExtensions.FilterErrorModes.Off;
     this._extender.DataGrid = this._grid;
     this._extender.FilterBoxPosition = GridExtensions.FilterPosition.Top;
     this._extender.FilterText = "Filter";
     this._extender.FilterTextVisible = true;
     this._extender.MessageErrorMode = GridExtensions.FilterErrorModes.General;
     this._extender.Operator = GridExtensions.LogicalOperators.And;
     this._extender.GridFilterBound += new GridExtensions.GridFilterEventHandler(this.OnGridFilterBound);
     this._extender.GridFilterUnbound += new GridExtensions.GridFilterEventHandler(this.OnGridFilterUnbound);
     this._extender.AfterFiltersChanged += new System.EventHandler(this.OnAfterFiltersChanged);
     this._extender.BeforeFiltersChanging += new System.EventHandler(this.OnBeforeFiltersChanging);
     //
     // FilterableDataGrid
     //
     this.Controls.Add(this._grid);
     this.Name = "FilterableDataGrid";
     this.Size = new System.Drawing.Size(496, 376);
     ((System.ComponentModel.ISupportInitialize)(this._grid)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this._extender)).EndInit();
     this.ResumeLayout(false);
 }
 public void AddStatement(Statement statement, LogicalOperators logicalOperator)
 {
     _statementAndLogicalOperators.Add(statement, logicalOperator);
 }
예제 #32
0
        public ODataFilter <T> AddFilter(Expression <Func <T, bool> > expression, LogicalOperators logicalOperators)
        {
            var odata = expression.ToOdataFilter();

            return(AddFilter(odata, logicalOperators));
        }
예제 #33
0
 public void AddJoinColumn(JoinColumn leftColumn, JoinColumn rightColumn,
                           RelationalOperators relationalOperator = RelationalOperators.Equal,
                           LogicalOperators logicalOperator       = LogicalOperators.And)
 {
     AddJoinColumn(new JoinColumnMap(leftColumn, rightColumn, relationalOperator, logicalOperator));
 }
예제 #34
0
 public ValidateAttribute(LogicalOperators op, params object[] values)
 {
     Op = op;
     Value = values ?? new[] {(object) null};
 }
 /// <summary>
 /// Creates a new <see cref="ComposedConditionNode{TConditionNode}"/>.
 /// </summary>
 /// <param name="logicalOperator">the logical operator.</param>
 /// <param name="childConditionNodes">the set of child condition nodes.</param>
 public ComposedConditionNode(LogicalOperators logicalOperator, IEnumerable <IConditionNode <TConditionNode> > childConditionNodes)
 {
     this.LogicalOperator     = logicalOperator;
     this.ChildConditionNodes = childConditionNodes;
 }