Exemple #1
0
        public INIBlock(string name)
        {
            exists = false;

            path = "<none>";

            id = -1;

            line = -1;

            type = "<unknown>";

            parameters  = new List <INIParameter>();
            xparameters = new HashSet <XMLParameter>();
            blocks      = new List <INIBlock>();

            valid      = false;
            references = new HashSet <INIBlock>();
            referenced = new HashSet <INIBlock>();

            errors = new List <ValidationError>();

            errors.Add(new ValidationError("This block does not exist but is referenced elsewhere.", ValidationError.XSeverity.ERROR, ValidationError.XType.BAD_REFERENCE_ERROR));

            nameValue = new INIValue(name, 0, null);
        }
Exemple #2
0
        private void AddToRefMap(INIBlock b)
        {
            if (b.Name == "<none>" || b.Name == null)
            {
                return;
            }
            // Add boolean instead?

            string key = b.Type.ToLower() + XMLValue.RefDelimiter + b.Name.ToLower();

            if (!refMap.ContainsKey(key))
            {
                refMap.Add(key, b);
            }
            else if (!b.Partial && !refMap[key].Partial)
            {
                INIBlock b2 = refMap[key];
                if (b.Parent != null || b2.Parent != null && b.Parent != b2.Parent)
                {
                    return;
                }

                bool alreadyAdded = false;
                foreach (ValidationError e in b2.Errors)
                {
                    if (e.Type == ValidationError.XType.CONFLICT_ERROR)
                    {
                        alreadyAdded = true;
                        break;
                    }
                }
                INIValue v1 = b.NameValue;
                INIValue v2 = b2.NameValue;

                v1.Errors.Add(new ValidationError("Block '" + b.Name + "' of type '" + b.Type + "' has a name conflict.", ValidationError.XSeverity.ERROR, ValidationError.XType.CONFLICT_ERROR));
                v1.Revalidate();

                if (!alreadyAdded)
                {
                    v2.Errors.Add(new ValidationError("Block '" + b2.Name + "' of type '" + b2.Type + "' has a name conflict.", ValidationError.XSeverity.ERROR, ValidationError.XType.CONFLICT_ERROR));
                    v2.Revalidate();
                }
            }
        }