Beispiel #1
0
        protected override void OnValidateReferences(Validation.ValidationContext validate)
        {
            base.OnValidateReferences(validate);

            // check out of range indices
            foreach (var idx in this._nodes)
            {
                validate.IsNullOrIndex(nameof(VisualChildren), idx, this.LogicalParent.LogicalNodes);
            }

            // checks if a root node is being used as a child.
            foreach (var node in this.LogicalParent.LogicalNodes)
            {
                if (this._nodes.Any(ridx => node._HasVisualChild(ridx)))
                {
                    validate.GetContext(node)._LinkThrow("Children", "Root nodes cannot be children.");
                }
            }

            // check duplicated indices
            // if (this._nodes.Distinct().Count() != this._nodes.Count) result.AddError(this, "has duplicated node references");
        }