Exemplo n.º 1
0
        public static ConfTopicMsgRangeDTO GetTopicMsgRange(this Data.EF.Conference conf, string topicMsgRange, bool required = false)
        {
            // Regex: ^(.+?)(\.(\d+)(\-(\d+))?)?$
            // Groups: 1 (topic), 3 (lo), 5 (hi)
            var regex = new Regex(@"^(.+?)(\.(\d+)\-?(\-(\d+))?)?$");
            var match = regex.Match(topicMsgRange);

            if (!match.Success)
            {
                return(null);
            }
            var result = new ConfTopicMsgRangeDTO();

            if (match.Groups.Count >= 1)
            {
                result.topic = conf.GetTopicFromStr(match.Groups[1].Value, required);
            }
            if (match.Groups.Count >= 3 && int.TryParse(match.Groups[3].Value, out int i))
            {
                result.msgLow = i;
            }
            if (match.Groups.Count >= 5 && int.TryParse(match.Groups[5].Value, out i))
            {
                result.msgHigh = i;
            }

            if (!topicMsgRange.EndsWith("-") && result.msgHigh == 0)
            {
                result.msgHigh = result.msgLow;
            }

            return(result);
        }
Exemplo n.º 2
0
        private void ConfDir(Data.EF.Conference conf)
        {
            var selTopics = conf.ConfTopics;

            foreach (var topic in selTopics.OrderBy(t => t.TopicNo))
            {
                session.terminal.Line(ConfFormatter.FormatTopic(topic));
            }
        }
Exemplo n.º 3
0
        public static ConfTopic GetTopicFromStr(this Data.EF.Conference conf, string topicName, bool Required = false)
        {
            // All?
            if (topicName == "*")
            {
                return(null);
            }

            // Numeric?
            if (int.TryParse(topicName, out int topicNo))
            {
                // check the number is valid
                if (topicNo > 0)
                {
                    var topic = conf.ConfTopics.Where(t => t.TopicNo == topicNo).FirstOrDefault();
                    if (topic != null)
                    {
                        return(topic);
                    }
                    throw new ArgumentException(string.Format(strings.Conf_UnknownTopic, topicNo));
                }
            }

            if (conf.ConfTopics.Count(t => t.Name.StartsWith(topicName)) == 1)
            {
                var topic = conf.ConfTopics.First(t => t.Name.StartsWith(topicName));
                return(topic);
            }

            if (Required)
            {
                throw new ArgumentException(string.Format(strings.Conf_UnknownTopic, topicName));
            }

            return(null);
        }