Exemplo n.º 1
0
        /// <summary>
        /// Helper method to parse a string into rule actions
        /// </summary>
        /// <param name="acts">the string to parse into actions</param>
        /// <returns>An array of the parsed actions</returns>
        private Action[] StringToActions(string acts)
        {
            //split string by ANDs
            string[] buff = acts.Split(new string[] { " AND " }, StringSplitOptions.None);
            if (buff.Contains(""))
            {
                throw new ArgumentException("Illegal AND statement in actions");
            }

            //check each split string to match a valid action
            Action[] returned = new Action[buff.Length];
            for (int c = 0; c < buff.Length; c++)
            {
                if (buff[c].Contains("NOTIFY"))
                {
                    returned[c] = new AlertAction(alert);
                }
                else if (buff[c].Contains("ALERT"))
                {
                    returned[c] = new AlertAction(alert);
                }
                else if (buff[c].Contains("KILL"))
                {
                    returned[c] = new CancelAction(kill);
                }
                else
                {
                    throw new ArgumentException("Unsupported Action");
                }
            }

            return(returned);
        }
        /// <summary>
        /// Helper method to parse a string into rule actions
        /// </summary>
        /// <param name="acts">the string to parse into actions</param>
        /// <returns>An array of the parsed actions</returns>
        private Action[] StringToActions(string acts)
        {
            //split string by ANDs
            string[] buff = acts.Split(new string[] { " AND " }, StringSplitOptions.None);
            if (buff.Contains(""))
                throw new ArgumentException("Illegal AND statement in actions");

            //check each split string to match a valid action
            Action[] returned = new Action[buff.Length];
            for (int c = 0; c < buff.Length; c++)
            {
                if (buff[c].Contains("NOTIFY"))
                    returned[c] = new AlertAction(alert);
                else if (buff[c].Contains("ALERT"))
                    returned[c] = new AlertAction(alert);
                else if (buff[c].Contains("KILL"))
                    returned[c] = new CancelAction(kill);
                else
                    throw new ArgumentException("Unsupported Action");
            }

            return returned;
        }