Example #1
0
        public static SpecialCondition[] ParseConditions(string rawLine)
        {
            List <SpecialCondition> conditions = new List <SpecialCondition>();

            string[] rawConditions = rawLine.Trim().Split(';');

            for (int i = 0; i < rawConditions.Length; i++)
            {
                string[] conditionArgs = rawConditions[i].Trim().Split(',');

                SpecialConditionType type = (SpecialConditionType)Enum.Parse(typeof(SpecialConditionType), conditionArgs[0]);

                SpecialCondition newCondition;

                switch (type)
                {
                case SpecialConditionType.BrokenLengthMatch:
                    newCondition = new BrokenLengthMatch(conditionArgs);
                    break;

                case SpecialConditionType.LengthMatch:
                    newCondition = new LengthMatch(conditionArgs);
                    break;

                case SpecialConditionType.RangeRestrict:
                    newCondition = new RangeRestrict(conditionArgs);
                    break;

                default:
                    throw new NotImplementedException(string.Format("{0} not implemented!", Convert.ToString(type)));
                }

                conditions.Add(newCondition);
            }

            return(conditions.ToArray());
        }
        public static SpecialCondition[] ParseConditions(string rawLine)
        {
            List<SpecialCondition> conditions = new List<SpecialCondition>();

            string[] rawConditions = rawLine.Trim().Split(';');

            for (int i = 0; i < rawConditions.Length; i++)
            {
                string[] conditionArgs = rawConditions[i].Trim().Split(',');

                SpecialConditionType type = (SpecialConditionType)Enum.Parse(typeof(SpecialConditionType), conditionArgs[0]);

                SpecialCondition newCondition;

                switch (type)
                {
                    case SpecialConditionType.BrokenLengthMatch:
                        newCondition = new BrokenLengthMatch(conditionArgs);
                        break;
                    case SpecialConditionType.LengthMatch:
                        newCondition = new LengthMatch(conditionArgs);
                        break;
                    case SpecialConditionType.RangeRestrict:
                        newCondition = new RangeRestrict(conditionArgs);
                        break;
                    default:
                        throw new NotImplementedException(string.Format("{0} not implemented!", Convert.ToString(type)));
                }

                conditions.Add(newCondition);
            }

            return conditions.ToArray();
        }