Exemple #1
0
        public void AddParameter(XMLParameter p)
        {
            foreach (XMLParameter p2 in parameters)
            {
                if (p2.Name == p.Name)
                {
                    p2.Add(p);

                    return;
                }
            }

            parameters.Add(p);
        }
Exemple #2
0
        private bool ParseAlternate(XMLParameter x, List <ValidationError> localErrors)
        {
            bool currValid = true;

            int off = 0;

            for (int a = 0; a < values.Length; a++)
            {
                if (a - off >= x.Count)
                {
                    localErrors.Add(new ValidationError("Parameter '" + this.Name + "' has too many values.", ValidationError.XSeverity.ERROR, ValidationError.XType.MISSING_ERROR));
                    return(false);
                }
                values[a].Xml = x[a - off];
                if (values[a].Valid && (x[a - off].Behavior & XMLValue.XBehavior.REPEATABLE) == XMLValue.XBehavior.REPEATABLE)
                {
                    off++;
                }
                else if (!values[a].Valid && off > 0)
                {
                    off--;
                    a--;
                    continue;
                }

                currValid = currValid && values[a].Valid;
                localErrors.AddRange(values[a].Errors);
            }
            foreach (INIValue v in values)
            {
                if (v.Xml == null)
                {
                    localErrors.Add(new ValidationError("Parameter '" + this.Name + "' has missing values.", ValidationError.XSeverity.ERROR, ValidationError.XType.MISSING_ERROR));
                    currValid = false;
                }
            }

            return(currValid);
        }
Exemple #3
0
        public bool Match(XMLParameter x)
        {
            if (xml != null || x.Name != name.ToLower())
            {
                return(false);
            }

            xml = x;

            List <ValidationError> localErrors = new List <ValidationError>();

            if (ParseAlternate(x, localErrors))
            {
                return(true);
            }

            if (x.Alternates != null)
            {
                foreach (XMLParameter x2 in x.Alternates)
                {
                    localErrors.Clear();
                    if (ParseAlternate(x2, localErrors))
                    {
                        xml = x2;
                        return(true);
                    }
                }
            }

            valid = false;
            if (x.Alternates != null)
            {
                xml = x.Alternates[x.Alternates.Count - 1];
            }
            errors.AddRange(localErrors);

            return(true);
        }
Exemple #4
0
 public void Clear()
 {
     xml   = null;
     valid = true;
     errors.Clear();
 }