Exemple #1
0
        // Called after loading. This will check internal fields and fill in consistency data.
        internal void OnLoadComplete(ErrorContainer errors)
        {
            // Do integrity checks.
            if (_header == null)
            {
                errors.FormatNotSupported("Missing header file");
                throw new DocumentException();
            }
            if (_properties == null)
            {
                errors.FormatNotSupported("Missing properties file");
                throw new DocumentException();
            }

            // Will visit all controls and add errors
            var uniqueVisitor = new UniqueControlNameVistor(errors);

            foreach (var control in _screens.Values.Concat(_components.Values))
            {
                uniqueVisitor.Visit(control);
            }


            // Integrity checks.
            foreach (var kv in _connections.NullOk())
            {
                var connection = kv.Value;

                if (kv.Key != connection.id)
                {
                    errors.FormatNotSupported($"Document consistency error. Connection id mismatch");
                    throw new DocumentException();
                }
            }
        }
        // Called after loading. This will check internal fields and fill in consistency data.
        internal void OnLoadComplete(ErrorContainer errors)
        {
            // Do integrity checks.
            if (_header == null)
            {
                errors.FormatNotSupported("Missing header file");
                throw new DocumentException();
            }
            if (_properties == null)
            {
                errors.FormatNotSupported("Missing properties file");
                throw new DocumentException();
            }

            // Will visit all controls and add errors
            var uniqueVisitor = new UniqueControlNameVistor(errors);

            foreach (var control in _screens.Values.Concat(_components.Values))
            {
                uniqueVisitor.Visit(control);
            }


            // Integrity checks.
            // Make sure every connection has a corresponding data source.
            foreach (var kv in _connections.NullOk())
            {
                var connection = kv.Value;

                if (kv.Key != connection.id)
                {
                    errors.FormatNotSupported($"Document consistency error. Connection id mismatch");
                    throw new DocumentException();
                }
                foreach (var dataSourceName in connection.dataSources)
                {
                    var ds = _dataSources.SelectMany(x => x.Value).Where(x => x.Name == dataSourceName).FirstOrDefault();
                    if (ds == null)
                    {
                        errors.ValidationError($"Connection '{dataSourceName}' does not have a corresponding data source.");
                        throw new DocumentException();
                    }
                }
            }
        }