Exemple #1
0
        public void TryParse_NoMatch_Empty()
        {
            SimpleExpressionSection value;
            bool result = SimpleExpressionSection.TryParse(null, ExpressionSectionType.Hour, out value);

            Assert.False(result);
        }
Exemple #2
0
        public void TryParse_NoMatch5()
        {
            SimpleExpressionSection value;
            bool result = SimpleExpressionSection.TryParse("60", ExpressionSectionType.Minute, out value);

            Assert.False(result);
        }
Exemple #3
0
        public void TryParse_NoMatch4()
        {
            SimpleExpressionSection value;
            bool result = SimpleExpressionSection.TryParse("8", ExpressionSectionType.DayOfWeek, out value);

            Assert.False(result);
        }
Exemple #4
0
        public void TryParse_NoMatch3()
        {
            SimpleExpressionSection value;
            bool result = SimpleExpressionSection.TryParse("13", ExpressionSectionType.Month, out value);

            Assert.False(result);
        }
Exemple #5
0
        public void TryParse_Match1()
        {
            SimpleExpressionSection value;
            bool result = SimpleExpressionSection.TryParse("1", ExpressionSectionType.Hour, out value);

            Assert.True(result);
            Assert.AreEqual(1, value.Value);
        }
        static public bool TryParse(string s, ExpressionSectionType type, out SimpleExpressionSection result)
        {
            result = default(SimpleExpressionSection);
            if (string.IsNullOrEmpty(s)) return false;

            int value;

            if (!int.TryParse(s, out value)) return false;
            if (!ValidateValue(type, value)) return false;

            result = new SimpleExpressionSection();
            result.Type = type;
            result.Value = value;
            return true;
        }
        static public bool TryParse(string s, ExpressionSectionType type, out SimpleExpressionSection result)
        {
            result = default(SimpleExpressionSection);
            if (string.IsNullOrEmpty(s))
            {
                return(false);
            }

            int value;

            if (!int.TryParse(s, out value))
            {
                return(false);
            }
            if (!ValidateValue(type, value))
            {
                return(false);
            }

            result       = new SimpleExpressionSection();
            result.Type  = type;
            result.Value = value;
            return(true);
        }