コード例 #1
0
        public static bool MatchesVersion(ModMetaData mod, EqualityOperator op, Version version, bool unknownResult = false)
        {
            var modVersion = Manifest.For(mod)?.Version;

            if (modVersion == null || version == null)
            {
                return(unknownResult);
            }

            switch (op)
            {
            case EqualityOperator.Equal:
                return(version == modVersion);

            case EqualityOperator.Exists:
                return(mod != null);

            case EqualityOperator.GreaterEqual:
                return(modVersion >= version);

            case EqualityOperator.LesserEqual:
                return(modVersion <= version);

            default:
                return(unknownResult);
            }
        }
コード例 #2
0
 public static void IsExampleOfOperatorIsUsing()
 {
     if ((EqualityOperator.IsExampleOfValueTypesEquality(5, 5)) is true)
     {
         Console.WriteLine("\n При сравнении двух одинаковых целочисленных значений  возвращаеться true");
     }
 }
コード例 #3
0
 public static void WriteEqualityOperator(Context context, EqualityOperator equalityOperator)
 {
     Write(context, '(');
     WriteExpression(context, equalityOperator.Left);
     Write(context, " == ");
     WriteExpression(context, equalityOperator.Right);
     Write(context, ')');
 }
        public void Test_can_map_equality_operator_to_compare_condition(EqualityOperator operatr, CompareCondition condition)
        {
            QueryConditionToPropertyCriteriaMapper mapper =
                new QueryConditionToPropertyCriteriaMapper(
                    new PropertyDataTypeResolver(new ContentType()));

            CompareCondition mappedCondition = mapper.MapEqualityOperatorToCompareCondition(operatr);

            mappedCondition.ShouldBeEquivalentTo(condition);
        }
コード例 #5
0
        private SimpleConditional TryParseSimpleConditional()
        {
            Expression left = TryParseExpression();

            if (left is null)
            {
                return(null);
            }

            EqualityOperator equalityOperator = TryParseEqualityOperator() ?? throw new UnexpectedToken(_scanner.CurrentToken.Position);
            Expression       right            = TryParseExpression() ?? throw new UnexpectedToken(_scanner.CurrentToken.Position);

            return(new SimpleConditional(left, right, equalityOperator));
        }
コード例 #6
0
        public static string OperatorToString(EqualityOperator op)
        {
            switch (op)
            {
            case EqualityOperator.Equal:
                return("==");

            case EqualityOperator.GreaterEqual:
                return(">=");

            case EqualityOperator.LesserEqual:
                return("<=");

            default:
                return("");
            }
        }
コード例 #7
0
        internal CompareCondition MapEqualityOperatorToCompareCondition(EqualityOperator operatr)
        {
            switch (operatr)
            {
            case EqualityOperator.Equals:
                return(CompareCondition.Equal);

            case EqualityOperator.GreaterThan:
                return(CompareCondition.GreaterThan);

            case EqualityOperator.LessThan:
                return(CompareCondition.LessThan);

            case EqualityOperator.NotEquals:
                return(CompareCondition.NotEqual);
            }

            throw new InvalidOperationException($"Equality operator '{operatr}' not supported.");
        }
コード例 #8
0
        public static bool EvaluateSimpleConditional(Value left, Value right, EqualityOperator o)
        {
            if (left.Type != right.Type)
            {
                throw new ArthmeticOperationException("Cannot compare various types: " + left.Type + " and " + right.Type);
            }

            if (left.Type == TypeValue.Int)
            {
                return(intComparator[o.Operator](left as Int_t, right as Int_t));
            }
            else if (left.Type == TypeValue.Matrix && matrixComparator.ContainsKey(o.Operator))
            {
                return(matrixComparator[o.Operator](left as Matrix_t, right as Matrix_t));
            }
            else if (left.Type == TypeValue.String && stringComparator.ContainsKey(o.Operator))
            {
                return(stringComparator[o.Operator](left as String_t, right as String_t));
            }
            else
            {
                throw new ArthmeticOperationException("Operator: " + o.Operator + " does not match to type: " + left.Type);
            }
        }
コード例 #9
0
ファイル: QueryField.cs プロジェクト: maheshbailwal2/Projects
 public QueryField(string searchField, EqualityOperator equalityOperator, object searchValue)
 {
     SearchField      = searchField;
     EqualityOperator = equalityOperator;
     SearchValue      = searchValue;
 }
コード例 #10
0
 public override void Visit(EqualityOperator binaryOperator)
 {
     Visit(binaryOperator.Left);
     Write(" == ");
     Visit(binaryOperator.Right);
 }
コード例 #11
0
 public LiteralComparison(dynamic expected, EqualityOperator equalityOperator) : base(i => expected, equalityOperator)
 {
 }
コード例 #12
0
 private IEnumerable <ITestRule> GetEqualityOperatorReturns(T instance, T other, bool result, string testCase) =>
 EqualityOperator.Select(
     method => MethodReturns <T, bool> .Operator(method, "operator ==", instance, other, result, testCase));
コード例 #13
0
ファイル: Operators.cs プロジェクト: kubast/wpfLight
        public void Test()
        {
            BinaryOperators o1 = new BinaryOperators()
            {
                X = 20, Y = 12
            };
            BinaryOperators o2 = new BinaryOperators()
            {
                X = 30, Y = 38
            };
            BinaryOperators o3 = o1 + o2;

            o3 += 2;
            Console.WriteLine("o3.X {0}, o3.Y {1}", o3.X, o3.Y);

            UnaryOperators uOp1 = new UnaryOperators()
            {
                X = 100, Y = 200
            };

            Console.WriteLine("uOp1.X {0}, uOp1.Y {1}", uOp1.X, uOp1.Y);
            uOp1++;
            ++uOp1;
            Console.WriteLine("uOp1.X {0}, uOp1.Y {1}", uOp1.X, uOp1.Y);

            EqualityOperator eo1 = new EqualityOperator()
            {
                X = 100, Y = 200
            };
            EqualityOperator eo2 = new EqualityOperator()
            {
                X = 100, Y = 200
            };

            Console.WriteLine("eo1 == eo2 {0}   eo1.Equals(eo2) {1} ", eo1 == eo2, eo1.Equals(eo2));
            ComparisonOperator co1 = new ComparisonOperator()
            {
                X = 2, Y = 2
            };
            ComparisonOperator co3 = new ComparisonOperator()
            {
                X = 6, Y = 6
            };
            ComparisonOperator co2 = new ComparisonOperator()
            {
                X = 4, Y = 4
            };

            Console.WriteLine(" co1 < co2  {0}", co1 < co2);
            Console.WriteLine(" co1 < co2  {0}", co1 > co2);
            Console.WriteLine(" co3 < co2  {0}", co3 > co2);


            CustomConversionA customA = new CustomConversionA()
            {
                Description = "My Description"
            };
            CustomConversionC customC = new CustomConversionC()
            {
                Description = "My Description"
            };

            CustomConversionB customBfromA    = (CustomConversionB)customA;
            CustomConversionB customBfromCex  = (CustomConversionB)customC;
            CustomConversionB customBfromCimp = customC;

            Console.WriteLine("CustomBfromA : {0}", customBfromA.ReverseDescription);
            Console.WriteLine("CustomBfromC(explicit) :  {0}", customBfromCex.ReverseDescription);
            Console.WriteLine("CustomBfromC(implpicit) : {0}", customBfromCimp.ReverseDescription);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            // Инициализация переменных всех типов.

            bool    boolVariable    = true;
            byte    byteVariable    = 17;
            sbyte   sbyteVariable   = -17;
            char    charVariable    = 'M';
            decimal decimalVariable = 7.99999999999m;
            double  doubleVariable  = 47.2;
            float   floatVariable   = 3.3f;
            int     intVariable     = 9;
            uint    uintVariable    = 0b1101;
            long    longVariable    = 11;
            ulong   ulongVariable   = 0;
            short   shortVariable   = -32768;
            object  objectVariable  = "Hi";
            string  stringVariable  = "tragedy = tragos + ödö = goats song";
            dynamic dynamicVariable = 4;

            dynamicVariable = "string";

            // Использование операторов

            ArithmeticOperator.UseDivisionOperator(8, 5);
            ArithmeticOperator.UseDivisionOperator(7.2f, 3.6f);
            ArithmeticOperator.UseMultiplicationOperator(11, 12);
            ArithmeticOperator.UsePostfixIncrementOperator(5);
            ArithmeticOperator.UsePrefixIncrementOperator(5);
            ArithmeticOperator.UsePostfixDecreaseOperator(5);
            ArithmeticOperator.UsePrefixDecreaseOperator(5);
            ArithmeticOperator.UseUnaryMinusOperator(36);
            ArithmeticOperator.UseUnaryPlusOperator(-4);
            ArithmeticOperator.UseAdditionOperator(3, 4);
            ArithmeticOperator.UseSubtractionOperator(-3, 8);
            ArithmeticOperator.UseIntegerRemainderOperator(10, 3);
            ArithmeticOperator.UseFloatingPointRemainderOperator(89.3f, 34.2f);

            EqualityOperator.IsExampleOfValueTypesEquality(3, 3);
            EqualityOperator.IsExampleOfReferenceTypesEquality();
            EqualityOperator.IsExampleOfRecordTypesEquality();
            EqualityOperator.IsExampleIfStringEquality("Harry Potter", "Hobbit");
            EqualityOperator.IsExampleDelegateEquality();
            EqualityOperator.IsExampleOfInequalityOperatorUsing(8, 3);

            LogicalOperator.UseLogicalNegationOperator(true);
            LogicalOperator.UseLogicalAndOperator(false, true);
            LogicalOperator.UseLogicalExclusionOrOperator(false, true);
            LogicalOperator.UseLogicalOrOperator(false, true);
            LogicalOperator.UseConditionalLogicalAndOperator(false, true);
            LogicalOperator.UseConditionalLogicalOrOperator(false, true);

            TypeCheckingOperator.IsExampleOfOperatorIsUsing();
            TypeCheckingOperator.IsExampleOfOperatorAsUsing();
            TypeCheckingOperator.IsExampleOfCastExpressionUsing();

            BitwiseOperatorAndShiftOperator.UseBitwiseComplementOperator();
            BitwiseOperatorAndShiftOperator.UseLeftShiftOperator(3);
            BitwiseOperatorAndShiftOperator.UseRightShiftOperator(4);
            BitwiseOperatorAndShiftOperator.UseLogicalExclusionOrOperator();
            BitwiseOperatorAndShiftOperator.UseLogicalAndOperator();
            BitwiseOperatorAndShiftOperator.UseLogicalOrOperator();

            ComparisonOperator.UseOperatorLessThan(5, 6);
            ComparisonOperator.UseOperatorMoreThan(9, 6);
            ComparisonOperator.UseOperatorLessThanOrEqual(5, 5);
            ComparisonOperator.UseOperatorMoreThanOrEqual(0, -4);
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestApiQueryFilter"/> class.
 /// </summary>
 /// <param name="searchField">
 /// Name of the field being searched.
 /// </param>
 /// <param name="equalityOperator">
 /// The equality Operator.
 /// </param>
 /// <param name="searchValue">
 /// Value that is being searched.
 /// </param>
 public TestApiQueryFilter(string searchField, EqualityOperator equalityOperator, object searchValue)
 {
     this.SearchField      = searchField;
     this.SearchValue      = searchValue;
     this.EqualityOperator = equalityOperator;
 }
コード例 #16
0
ファイル: BooleanCondition.cs プロジェクト: shaunvxc/Deviant
 public BooleanCondition(Condition c1, EqualityOperator op, Condition c2)
 {
     this.c1 = c1;
     this.c2 = c2;
     this.op = op;
 }
コード例 #17
0
 public EqualityExpression(AbstractEqualityExpression equalityExpression, EqualityOperator equalityOperator, AbstractRelationalExpression relationalExpression, bool isStrictMode) : base(isStrictMode)
 {
     this.equalityExpression   = equalityExpression;
     this.equalityOperator     = equalityOperator;
     this.relationalExpression = relationalExpression;
 }
コード例 #18
0
 public SimpleConditional(Expression left, Expression right, EqualityOperator equality)
 {
     leftExpression   = left;
     rightExpression  = right;
     equalityOperator = equality;
 }
コード例 #19
0
 public Dependency(string id, EqualityOperator op, Version version)
 {
     Identifier = id;
     Operator   = op;
     Version    = version;
 }
コード例 #20
0
ファイル: Operators.cs プロジェクト: kubast/wpfLight
            public override bool Equals(object obj)
            {
                EqualityOperator eO2 = obj as EqualityOperator;

                return((this.X == eO2.X) && (this.Y == eO2.Y));
            }
コード例 #21
0
 public override void Visit(EqualityOperator binaryOperator)
 {
     WriteBinaryExpression(binaryOperator, "==");
 }
コード例 #22
0
 /// <summary>
 /// Initialises a new instance of <see cref="NegatedEqualityOperator"/>
 /// </summary>
 /// <param name="name">The name of the operator.</param>
 internal NegatedEqualityOperator(string name)
     : base(name)
 {
     _equalityOperator = new EqualityOperator(false);
 }
コード例 #23
0
 public virtual void Visit(EqualityOperator binaryOperator)
 {
     Visit(binaryOperator.Left);
     Visit(binaryOperator.Right);
 }
コード例 #24
0
 public TextFieldLengthValidationRule(EqualityOperator equalityOperator, int value) : base(
         nameof(TextFieldLengthValidationRule))
 {
     EqualityOperator = equalityOperator;
     Value            = value;
 }
コード例 #25
0
 /// <summary>
 /// Initialises a new instance of <see cref="NegatedEqualityOperator"/>
 /// </summary>
 /// <param name="strict">True if strict equality checking should be used, otherwise false.</param>
 public NegatedEqualityOperator(bool strict = false)
     : base(strict ? "!==" : "!=")
 {
     _equalityOperator = new EqualityOperator(strict);
 }
コード例 #26
0
 public FunctionComparison(Func <TInput, dynamic> expectedFunction, EqualityOperator equalityOperator) : base(expectedFunction)
 {
     EqualityOperator = equalityOperator;
 }