Ejemplo n.º 1
0
        public void IsOver_Test()
        {
            var between = new Between<int>(1, 3, 2);
            Console.WriteLine(between.IsOver);

            Assert.IsTrue(between.IsOver);
        }
 private void RefreshTextBoxes()
 {
     textBoxAngle.Text   = Angle.ToString("0.##");
     textBoxBetween.Text = Between.ToString("0.##");
     textBoxHeight.Text  = Height.ToString("0.##");
     textBoxNumber.Text  = Number.ToString();
 }
Ejemplo n.º 3
0
        public void EqualsDifferentType_Failure()
        {
            var operation    = new Between();
            var notOperation = "notOperation";

            operation.Equals(notOperation).Should().BeFalse();
        }
Ejemplo n.º 4
0
        public void GetExpressionTest()
        {
            var propertyName = "Salary";
            var operation    = new Between();
            var param        = Expression.Parameter(typeof(Person), "x");
            var member       = Expression.Property(param, propertyName);
            var constant1    = Expression.Constant(4000D);
            var constant2    = Expression.Constant(5000D);

            BinaryExpression expression = (BinaryExpression)operation.GetExpression(member, constant1, constant2);

            //Testing the operation structure
            expression.Left.Should().BeAnExpressionCheckingIf(propertyName, ExpressionType.GreaterThanOrEqual, 4000D);

            Assert.That(expression.NodeType, Is.EqualTo(ExpressionType.AndAlso));

            expression.Right.Should().BeAnExpressionCheckingIf(propertyName, ExpressionType.LessThanOrEqual, 5000D);

            //Testing the operation execution
            var lambda   = Expression.Lambda <Func <Person, bool> >(expression, param);
            var people   = TestData.People.Where(lambda.Compile());
            var solution = TestData.People.Where(x => x.Salary >= 4000 && x.Salary <= 5000);

            Assert.That(people, Is.EquivalentTo(solution));
        }
Ejemplo n.º 5
0
            public static int GetNumber(string msg1, string msg2,
                                        Between s, bool again = false)
            {
                int a;

                a = -1;
                try
                {
                    if (msg1 != null)
                    {
                        Console.Write(msg1);
                    }
                    if (msg2 != null && again)
                    {
                        Console.WriteLine(msg2);
                    }
                    a = Int32.Parse(Console.ReadLine());
                    if (!(a >= s.min && a <= s.max))
                    {
                        a = GetNumber(msg1, msg2, s, true);
                    }
                }
                catch (FormatException e)
                {
                    Console.WriteLine("Problem format ...");
                    a = GetNumber(msg1, msg2, s, true);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception e" + e.ToString());
                }
                return(a);
            }
Ejemplo n.º 6
0
            /// <summary>
            ///     Create token that matches provided string, string needs to be a single value
            /// </summary>
            /// <param name="tokenString"></param>
            /// <returns></returns>
            /// <exception cref="Exception"></exception>
            public static Token GetMatchingToken(string tokenString)
            {
                if (Equal.TryParse(tokenString, out var token))
                {
                    return(token);
                }
                if (LessThen.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (LessThenEqual.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (GreaterThen.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (GreaterThenEqual.TryParse(tokenString, out token))
                {
                    return(token);
                }
                if (Between.TryParse(tokenString, out token))
                {
                    return(token);
                }

                throw new Exception($"Provided string was invalid {tokenString}, please provide valid range token");
            }
Ejemplo n.º 7
0
        public void IsBetween_Test()
        {
            var between = new Between<int>(1, 2, 3);
            Console.WriteLine(between.IsBetween);

            Assert.IsTrue(between.IsBetween);
        }
Ejemplo n.º 8
0
        public void IsNotBetween_Test()
        {
            var between = new Between<int>(1, 3, 2);
            Console.WriteLine(between.IsBetween);

            Assert.IsFalse(between.IsBetween);
        }
Ejemplo n.º 9
0
        public void Equals_Test()
        {
            var between = new Between<int>(1,1,1);
            Console.WriteLine(between.IsBetween);

            Assert.IsTrue(between.IsBetween);
        }
Ejemplo n.º 10
0
        public void DateTimeNotBetween_Test()
        {
            var between = new Between<DateTime>(DateTime.Now, DateTime.Now, DateTime.Now.AddSeconds(-1));
            Console.WriteLine(between.IsBetween);

            Assert.IsFalse(between.IsBetween);
        }
Ejemplo n.º 11
0
 public Context()
 {
     MovementDate = new Between <DateTime?>();
     Location     = new Between <string>()
     {
         From = String.Empty, To = String.Empty
     };
 }
Ejemplo n.º 12
0
 private void Expand(Between between)
 {
     ExpandExpression(between.TestExpression);
     builder.Append(" between ");
     ExpandExpression(between.LeftExpression);
     builder.Append(" and ");
     ExpandExpression(between.RightExpression);
 }
Ejemplo n.º 13
0
        public bool Between_IsValid(int propertyValue, int floor, int ceiling)
        {
            //Create Validator
            var validator = new Between <Contact, int>(floor, ceiling);
            RuleValidatorContext <Contact, int> context = BuildContextForNumberOfDependents(propertyValue);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
 private void AddDefaultValues(double length)
 {
     Reverse             = 1;
     Height              = length;
     Angle               = 18;
     Number              = 10;
     Between             = Height / (Number - 1);
     textBoxAngle.Text   = Angle.ToString();
     textBoxBetween.Text = Between.ToString();
     textBoxHeight.Text  = Height.ToString();
     textBoxNumber.Text  = Number.ToString();
 }
Ejemplo n.º 15
0
        public bool Between_Expressions_IsValid(int propertyValue, int floor, int ceiling)
        {
            //Create Validator
            var validator = new Between <Contact, int>(c => c.NumberOfChildren, c => c.NumberOfDependents);
            RuleValidatorContext <Contact, int> context = BuildContextForNumberOfDependents(propertyValue);

            context.Instance.NumberOfDependents = ceiling;
            context.Instance.NumberOfChildren   = floor;

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
Ejemplo n.º 16
0
 private void ProcessSectionBetween(Between between)
 {
     foreach (Directive directive in between.Directives)
     {
         if (directive is DynamicText)
         {
             ProcessDynamicText((DynamicText)directive);
         }
         else if (directive is Text)
         {
             ProcessSectionText((Text)directive);
         }
     }
 }
Ejemplo n.º 17
0
 private void ProcessBetween(Between between, string writerKey)
 {
     foreach (Directive directive in between.Directives)
     {
         if (directive is DynamicText)
         {
             ProcessDynamicText((DynamicText)directive);
         }
         else if (directive is Text)
         {
             ProcessText((Text)directive, writerKey);
         }
     }
 }
Ejemplo n.º 18
0
        private void ParseBetweenStartIfAny(string line)
        {
            Assertion.Assert(line != null, "line cannot be null.");

            if (betweenStartHandlingExpr.IsMatch(line))
            {
                Between between = new Between();
                this.currentDirective.Directives.Add(between);
                this.currentDirective = between;

                this.contextStack.Push(new Context(
                                           TemplateMode.Dynamic, string.Empty));
            }
        }
Ejemplo n.º 19
0
 public PermissionMaterialFilter()
 {
     CreationDate = new Between <DateTime?>();
     States       = new List <PermissionMaterialState>
     {
         PermissionMaterialState.New,
         PermissionMaterialState.Confirming,
         PermissionMaterialState.ConfirmingExtension,
         PermissionMaterialState.Confirmed,
         PermissionMaterialState.NotConfirmed,
         PermissionMaterialState.Closed
     };
     StateDate    = new Between <DateTime?>();
     AcceptToDate = new Between <DateTime?>();
 }
Ejemplo n.º 20
0
            public new static Between FromJsonToken(JToken token)
            {
                //IL_0001: Unknown result type (might be due to invalid IL or missing references)
                //IL_0007: Invalid comparison between Unknown and I4
                //IL_000f: Unknown result type (might be due to invalid IL or missing references)
                if ((int)token.get_Type() != 1)
                {
                    Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                    return(null);
                }
                JObject jsonObject = Extensions.Value <JObject>((IEnumerable <JToken>)token);
                Between between    = new Between();

                between.PopulateFromJson(jsonObject);
                return(between);
            }
Ejemplo n.º 21
0
        public bool Between_CeilingExpression_IsValid(string createDate, string startDate, string endDate)
        {
            DateTime createDateTime = DateTime.Parse(createDate);
            DateTime startDateTime  = DateTime.Parse(startDate);
            DateTime endDateTime    = DateTime.Parse(endDate);

            //Create Validator
            var validator = new Between <CalendarEvent, DateTime>(createDateTime, c => c.EndDate);
            RuleValidatorContext <CalendarEvent, DateTime> context = BuildContextForCalendarEventStartDate("Test Event",
                                                                                                           createDateTime,
                                                                                                           startDateTime,
                                                                                                           endDateTime);
            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
Ejemplo n.º 22
0
            protected override ICloneableElement Clone(Dictionary <ICloneableElement, ICloneableElement> objectTree, Predicate <ICloneableElement> doClone)
            {
                if (!doClone(this))
                {
                    return(this);
                }

                if (!objectTree.TryGetValue(this, out var clone))
                {
                    objectTree.Add(this, clone = new Between(
                                       (ISqlExpression)Expr1.Clone(objectTree, doClone),
                                       IsNot,
                                       (ISqlExpression)Expr2.Clone(objectTree, doClone),
                                       (ISqlExpression)Expr3.Clone(objectTree, doClone)));
                }

                return(clone);
            }
Ejemplo n.º 23
0
            public static bool TryParse(string tokenString, out Token token)
            {
                var split = tokenString.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries);

                if (int.TryParse(split[0], out var lessThen) &&
                    int.TryParse(split[1], out var greaterThen))
                {
                    token = new Between()
                    {
                        _lessThen    = lessThen < greaterThen ? lessThen : greaterThen,
                        _greaterThen = lessThen < greaterThen ? greaterThen : lessThen,
                    };
                    return(true);
                }

                token = null;
                return(false);
            }
Ejemplo n.º 24
0
            public static Common.GameUtils.Bet CreateBet()
            {
                Common.GameUtils.Bet bet = new GameUtils.Bet();
                Between bPoints          = new Between(0, 180);

                Common.IO.OutputManager.Standard.Client.AskBet();
                //Console.Write(Common.IO.Messages.Suit.SuitInfo + "? ");
                bet.suit = GetSuit(GetNumber(Common.IO.Messages.Suit.SuitInfo + "? ",
                                             "Please enter a number between 1-4", new Between(1, 4)));
                bet.points = GetNumber("Enter number of points you want bet ("
                                       + bPoints.min + "-" + bPoints.max + ") ?", "",
                                       bPoints);
                bet.player      = null;
                bet.team        = null;
                bet.coinched    = false;
                bet.surcoinched = false;
                bet.id          = 0;
                return(bet);
            }
Ejemplo n.º 25
0
        public static IQueryOver <TEntity, TEntity> IsBetween <TEntity, U>(
            this IQueryOver <TEntity, TEntity> query,
            Expression <Func <TEntity, object> > property,
            Between <U> between)
        {
            if (between == null)
            {
                return(query);
            }

            if (object.Equals(between.From, null) || object.Equals(between.To, null))
            {
                return(query);
            }

            return(query.WhereRestrictionOn(property)
                   .IsBetween(between.From)
                   .And(between.To));
        }
Ejemplo n.º 26
0
 public CuttingOrderFilter()
 {
     AssumeDate              = new Between <DateTime?>();
     CreationDate            = new Between <DateTime?>();
     Creator                 = UserFilter.Default;
     DateDocumentIntegration = new Between <DateTime?>();
     Department              = StaffingDivisionFilter.Default;
     District                = StaffingDivisionFilter.Default;
     Inspector               = UserFilter.Default;
     Priority                = new List <CuttingOrderPriority>
     {
         CuttingOrderPriority.FirstPriority,
         CuttingOrderPriority.SecondPriority
     };
     State = new List <CuttingOrderState> {
         CuttingOrderState.FirstState, CuttingOrderState.SecondState
     };
     Storekeeper = UserFilter.Default;
 }
Ejemplo n.º 27
0
 public PlanReceiptOrderFilter()
 {
     GroundDocumentDate = new Between <DateTime?>();
     CreationDate       = new Between <DateTime?>();
     StateDate          = new Between <DateTime?>();
     States             = new List <PlanReceiptOrderState>
     {
         PlanReceiptOrderState.Close,
         PlanReceiptOrderState.Confirm,
         PlanReceiptOrderState.NotСonfirm,
         PlanReceiptOrderState.PartWork
     };
     PlanCertificate             = PlanCertificateFilter.Default;
     StaffingDivision            = StaffingDivisionFilter.Default;
     StoreGasStationOilDepot     = StoreGasStationOilDepotFilter.Default;
     GroundTypeOfDocument        = TypeOfDocumentFilter.Default;
     GroundReceiptDocNumb        = string.Empty;
     GroundReceiptDocumentDate   = new Between <DateTime?>();
     GroundReceiptTypeOfDocument = TypeOfDocumentFilter.Default;
 }
Ejemplo n.º 28
0
 public UserFilter()
 {
     ActiveState = new Between <DateTime?>();
 }
Ejemplo n.º 29
0
        private void WriteCondition(LogicalExpression condition)
        {
            ArrayList args = new ArrayList();

            string format    = "";
            bool   isLogical = false;

            if (condition.VocabularyLink != null)
            {
                format = GetVocabDisplayString(condition.VocabularyLink.DefinitionId);
            }

            //======================================
            // AND
            //======================================
            if (condition is LogicalAnd)
            {
                isLogical = true;

                this.BeginList();

                this.BeginListItem();
                this.writer.WriteLine("<img src='RuleAnd.jpg'><SPAN class='TableTitle'>AND</SPAN>");
                this.EndListItem();

                foreach (LogicalExpression le in ((LogicalAnd)condition).Arguments)
                {
                    WriteCondition(le);
                }
                this.EndList();
            }
            //======================================
            // OR
            //======================================
            else if (condition is LogicalOr)
            {
                isLogical = true;

                this.BeginList();

                this.BeginListItem();
                this.writer.WriteLine("<img src='RuleOr.jpg'><SPAN class='TableTitle'>OR</SPAN>");
                this.EndListItem();

                foreach (LogicalExpression le in ((LogicalOr)condition).Arguments)
                {
                    WriteCondition(le);
                }
                this.EndList();
            }
            //======================================
            // NOT
            //======================================
            else if (condition is LogicalNot)
            {
                isLogical = true;

                this.BeginList();

                this.BeginListItem();
                this.writer.WriteLine("<img src='RuleNot.jpg'><SPAN class='TableTitle'>NOT</SPAN>");
                this.EndListItem();

                WriteCondition(((LogicalNot)condition).Argument);
                this.EndList();
            }

            if (!isLogical)
            {
                this.BeginList();
                this.BeginListItem();

                if (condition.VocabularyLink == null)
                {
                    format = GetFakePredicateDisplayString(condition);
                }
            }

            //======================================
            // RELATIONAL PREDICATE
            //======================================
            if (condition is RelationalPredicate)
            {
                RelationalPredicate predicate = condition as RelationalPredicate;

                string a1 = WriteTerm(predicate.LeftArgument);
                string a2 = WriteTerm(predicate.RightArgument);

                args.Add(a1);
                args.Add(a2);
            }

            //======================================
            // BEFORE
            //======================================
            if (condition is Before)
            {
                Before before = condition as Before;

                string a1 = WriteTerm(before.Time1);
                string a2 = WriteTerm(before.Time2);

                //if (before.Time1.VocabularyLink != null)
                //{
                //    a1 = GetVocabDisplayString(before.Time1.VocabularyLink.DefinitionId);
                //}

                //if (before.Time2.VocabularyLink != null)
                //{
                //    a2 = GetVocabDisplayString(before.Time2.VocabularyLink.DefinitionId);
                //} //CD 2014/03/04

                args.Add(a1);
                args.Add(a2);
            }

            if (condition is After)
            {
                After after = condition as After;

                string a1 = WriteTerm(after.Time1);
                string a2 = WriteTerm(after.Time2);

                //if (after.Time1.VocabularyLink != null)
                //{
                //    a1 = GetVocabDisplayString(after.Time1.VocabularyLink.DefinitionId);
                //}

                //if (after.Time2.VocabularyLink != null)
                //{
                //    a2 = GetVocabDisplayString(after.Time2.VocabularyLink.DefinitionId);
                //} //CD 2014/03/04

                args.Add(a1);
                args.Add(a2);
            }

            if (condition is Between)
            {
                Between between = condition as Between;

                string a1 = WriteTerm(between.Time1);
                string a2 = WriteTerm(between.Time2);
                string a3 = WriteTerm(between.Time3);

                if (between.Time1.VocabularyLink != null)
                {
                    a1 = GetVocabDisplayString(between.Time1.VocabularyLink.DefinitionId);
                }

                //if (between.Time2.VocabularyLink != null)
                //{
                //    a2 = GetVocabDisplayString(between.Time2.VocabularyLink.DefinitionId);
                //}

                //if (between.Time3.VocabularyLink != null)
                //{
                //    a3 = GetVocabDisplayString(between.Time3.VocabularyLink.DefinitionId);
                //} CD 2014/03/04

                args.Add(a1);
                args.Add(a2);
                args.Add(a3);
            }

            if (condition is Range)
            {
                Range range = condition as Range;

                string a1 = WriteTerm(range.TestValue);
                string a2 = WriteTerm(range.RangeLow);
                string a3 = WriteTerm(range.RangeHigh);

                //if (range.TestValue.VocabularyLink != null)
                //{
                //    a1 = GetVocabDisplayString(range.TestValue.VocabularyLink.DefinitionId);
                //}

                //if (range.RangeLow.VocabularyLink != null)
                //{
                //    a2 = GetVocabDisplayString(range.RangeLow.VocabularyLink.DefinitionId);
                //}

                //if (range.RangeHigh.VocabularyLink != null)
                //{
                //    a3 = GetVocabDisplayString(range.RangeHigh.VocabularyLink.DefinitionId);
                //} CD 2014/03/04

                args.Add(a1);
                args.Add(a2);
                args.Add(a3);
            }

            if (condition is Match)
            {
                Match match = condition as Match;

                string a1 = WriteTerm(match.RegularExpression);
                string a2 = WriteTerm(match.InputString);

                // Does not appear to be required MTB 2014/02/10
                //if (match.InputString.VocabularyLink != null)
                //{
                //    //a1 = GetVocabDisplayString(match.InputString.VocabularyLink.DefinitionId); MTB 6/02/2014 Match contains predicate bug
                //    a2 = GetVocabDisplayString(match.InputString.VocabularyLink.DefinitionId);
                //}

                //if (match.RegularExpression.VocabularyLink != null)
                //{
                //    //a2 = GetVocabDisplayString(match.RegularExpression.VocabularyLink.DefinitionId); MTB 6/02/2014 Match contains bug
                //    a1 = GetVocabDisplayString(match.RegularExpression.VocabularyLink.DefinitionId);
                //}

                args.Add(a1);
                args.Add(a2);
            }

            if (condition is Exists)
            {
                Exists exists = condition as Exists;

                string a1 = WriteTerm(exists.ObjReference);
                string a2 = WriteTerm(exists.MemberName);

                if (exists.ObjReference.VocabularyLink != null)
                {
                    a1 = GetVocabDisplayString(exists.ObjReference.VocabularyLink.DefinitionId);
                }

                if (exists.MemberName.VocabularyLink != null)
                {
                    a2 = GetVocabDisplayString(exists.MemberName.VocabularyLink.DefinitionId);
                }

                args.Add(a1);
                args.Add(a2);
            }

            if (args.Count > 0)
            {
                if (format.Length == 0)
                {
                    int argCounter = 0;
                    foreach (string arg in args)
                    {
                        format += "{" + argCounter.ToString() + "} ";
                        break;
                    }
                }

                this.writer.WriteLine("<span class='TableData'><b>{0}</b></span>", TryStringFormat(format, args.ToArray()));
            }
            else
            {
                this.writer.WriteLine("<span class='TableData'>{0}</span>", format);
            }

            //this.writer.WriteLine("<span class='TableData'>{0}</span>", format);

            if (!isLogical)
            {
                this.EndList();
                this.EndListItem();
            }
        }
Ejemplo n.º 30
0
 public void BetweenCorrectlyConvertsToJson()
 {
     var between = new Between<int>(10, 20, false);
     between.ToString().ShouldEqual(BetweenJson);
 }
Ejemplo n.º 31
0
        private void ParseBetweenStartIfAny(string line)
        {
            Assertion.Assert(line != null, "line cannot be null.");

            if (betweenStartHandlingExpr.IsMatch(line))
            {
                Between between = new Between();
                this.currentDirective.Directives.Add(between);
                this.currentDirective = between;

                this.contextStack.Push(new Context(
                    TemplateMode.Dynamic, string.Empty));
            }
        }
Ejemplo n.º 32
0
 public void AdderParmtaer(Enum Enum, object pramter, Condtion Condtion, Between Between, HandleProssesEnum ProssesEnum)
 {
     AdderParmtaer(Enum, pramter, RetunObject, ProssesEnum, Condtion, Between);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// لإضافة برامتير
 /// </summary>
 /// <param name="Enum">اسم قاعدة البيانات</param>
 /// <param name="pramter">القيمة</param>
 /// <param name="HandleOutputParamtterMaker">المعالجة</param>
 public void AdderParmtaer(Enum Enum, object pramter, HandleOutputParamtterMaker HandleOutputParamtterMaker, HandleProssesEnum ProssesEnum, Condtion Condtion, Between Between)
 {
     ListEnum.Add(Enum);
     ListObject.Add(pramter);
     listCommandOutDataObject.Add(HandleOutputParamtterMaker);
     ListCondetion.Add(Condtion);
     ListCondetionBetwen.Add(Between);
     ListProssesEnum.Add(ProssesEnum);
 }
Ejemplo n.º 34
0
 public static ReturnType between <Item, Property, ReturnType>(this IProvideAccessToMatchBuilders <Item, Property, ReturnType> extension_point, Property start, Property end) where Property : IComparable <Property>
 {
     return(extension_point.create(Between.values(start, end)));
 }
Ejemplo n.º 35
0
 private void ProcessBetween(Between between, string writerKey)
 {
     foreach (Directive directive in between.Directives)
     {
         if (directive is DynamicText)
         {
             ProcessDynamicText((DynamicText) directive);
         }
         else if (directive is Text)
         {
             ProcessText((Text) directive, writerKey);
         }
     }
 }
Ejemplo n.º 36
0
        public void BetweenCorrectlyConvertsToJson()
        {
            var between = new Between <int>(10, 20, false);

            between.ToString().ShouldEqual(BetweenJson);
        }
Ejemplo n.º 37
0
            public static Between FromJsonProperty(JObject jsonObject, string propertyName, Between defaultValue = null)
            {
                //IL_0011: Unknown result type (might be due to invalid IL or missing references)
                //IL_0018: Invalid comparison between Unknown and I4
                JProperty val = jsonObject.Property(propertyName);

                if (val == null || (int)val.get_Value().get_Type() == 10)
                {
                    return(defaultValue);
                }
                return(FromJsonToken(val.get_Value()));
            }
Ejemplo n.º 38
0
 private void ProcessSectionBetween(Between between)
 {
     foreach (Directive directive in between.Directives)
     {
         if (directive is DynamicText)
         {
             ProcessDynamicText((DynamicText) directive);
         }
         else if (directive is Text)
         {
             ProcessSectionText((Text) directive);
         }
     }
 }
Ejemplo n.º 39
0
        public static ValueFilter FromJsonToken(JToken token)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0007: Invalid comparison between Unknown and I4
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            if ((int)token.get_Type() != 1)
            {
                Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                return(null);
            }
            JObject val  = Extensions.Value <JObject>((IEnumerable <JToken>)token);
            JToken  val2 = default(JToken);

            if (!val.TryGetValue("type", ref val2))
            {
                Debug.LogWarning((object)"Malformed json: no 'type' property in object of class ValueFilter");
                return(null);
            }
            string      text = Extensions.Value <string>((IEnumerable <JToken>)val2);
            ValueFilter valueFilter;

            switch (text)
            {
            case "IsEven":
                valueFilter = new IsEven();
                break;

            case "IsOdd":
                valueFilter = new IsOdd();
                break;

            case "Between":
                valueFilter = new Between();
                break;

            case "EqualsTo":
                valueFilter = new EqualsTo();
                break;

            case "LowerThan":
                valueFilter = new LowerThan();
                break;

            case "GreaterThan":
                valueFilter = new GreaterThan();
                break;

            case "NotEqualsTo":
                valueFilter = new NotEqualsTo();
                break;

            case "LowerEqualThan":
                valueFilter = new LowerEqualThan();
                break;

            case "GreaterEqualThan":
                valueFilter = new GreaterEqualThan();
                break;

            default:
                Debug.LogWarning((object)("Unknown type: " + text));
                return(null);
            }
            valueFilter.PopulateFromJson(val);
            return(valueFilter);
        }