示例#1
0
        public static E <string> ValidateTime(IReadOnlyList <string> value)
        {
            if (value.Count == 0)
            {
                return(R.Ok);
            }
            var last   = value[value.Count - 1];
            var repeat = last == "repeat" || last == "repeat last";

            if (repeat && value.Count == 1)
            {
                return($"Specified 'repeat' without any previous value.");
            }

            var max = repeat ? value.Count - 2 : value.Count - 1;

            for (int i = 0; i <= max; i++)
            {
                var r = TomlTools.ValidateTime(value[i]);
                if (!r.Ok)
                {
                    return(r);
                }
            }
            return(R.Ok);
        }
示例#2
0
        public static TimeSpan?GetValueAsTime(this ConfigArray <string> conf, int index)
        {
            var value = conf.Value;

            if (value.Count == 0)
            {
                return(null);
            }
            var last   = value[value.Count - 1];
            var repeat = last == "repeat" || last == "repeat last";             // "repeat" might get removed for other loops, but for now keep as hidden alternative
            var max    = repeat ? value.Count - 2 : value.Count - 1;

            if (index <= max)
            {
                return(TomlTools.ParseTime(value[index]));
            }
            else
            {
                return(TomlTools.ParseTime(value[max]));
            }
        }