Пример #1
0
        private IRRuleToken ProcessRRulePart(string rrulePart)
        {
            var rruleKeyValue = SplitRRulePart(rrulePart);

            if (rruleKeyValue.Length != 2)
            {
                throw new RRuleTokenizeException(
                          $"RRule part {rrulePart} contains more than key/value");
            }

            var rruleKey   = rruleKeyValue[0];
            var rruleValue = rruleKeyValue[1];

            var rruleToken = ERRuleToken.SearchRRuleToken(rruleKey);

            if (rruleToken == null)
            {
                throw new RRuleTokenizeException($"RRule key {rruleKey} not found");
            }

            var valueInstance = ParseValue(rruleToken, rruleValue);

            if (valueInstance == null)
            {
                throw new RRuleTokenizeException($"RRule value {rruleValue} is not applicable for key {rruleKey}");
            }

            return(rruleToken.GetTokenInstance(valueInstance));
        }
Пример #2
0
        private IRRuleToken ProcessRRulePart(string rrulePart)
        {
            var rruleKeyValue = SplitRRulePart(rrulePart);

            if (rruleKeyValue.Length != 2)
            {
                throw new RRuleTokenizeException(string.Format("RRule part {0} contains more than key/value", rrulePart));
            }

            string rruleKey   = rruleKeyValue[0];
            string rruleValue = rruleKeyValue[1];

            ERRuleToken rruleToken = ERRuleToken.SearchRRuleToken(rruleKey);

            if (rruleToken == null)
            {
                throw new RRuleTokenizeException(string.Format("RRule key {0} not found", rruleKey));
            }

            object valueInstance = ParseValue(rruleToken, rruleValue);

            if (valueInstance == null)
            {
                throw new RRuleTokenizeException(string.Format("RRule value {0} is not applicable for key {1}", rruleValue, rruleKey));
            }

            return(rruleToken.GetTokenInstance(valueInstance));
        }