Beispiel #1
0
        public static bool TryParse(string value, out MonthWithAssociatedBinder result)
        {
            result = default(MonthWithAssociatedBinder);

            if (String.IsNullOrEmpty(value) ||
                value.Length != 2)
            {
                return(false);
            }

            int number;

            if (!Int32.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out number))
            {
                return(false);
            }

            if (number < 1 ||
                number > 12)
            {
                return(false);
            }

            result = new MonthWithAssociatedBinder(number);

            return(true);
        }
Beispiel #2
0
        public override bool TryBind(string value, IFormatProvider provider, out object result)
        {
            result = null;

            MonthWithAssociatedBinder r;

            bool success = MonthWithAssociatedBinder.TryParse(value, out r);

            if (success)
            {
                result = r;
            }

            return(success);
        }