Ejemplo n.º 1
0
        public TransitionGroupDocNode UpdatePrecursor(IdentityPath parent, TransitionGroupDocNode precursorDocNode)
        {
            CheckCancelled();
            AnnotationUpdater updater;

            _annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.precursor, out updater);
            IdentityPath identityPath = new IdentityPath(parent, precursorDocNode.TransitionGroup);

            if (updater != null || _precursorResultUpdater != null)
            {
                var precursor = new Precursor(SkylineDataSchema, identityPath);
                if (updater != null)
                {
                    var annotations = updater.UpdateAnnotations(precursorDocNode.Annotations, precursor);
                    if (!Equals(annotations, precursorDocNode.Annotations))
                    {
                        precursorDocNode = (TransitionGroupDocNode)precursorDocNode.ChangeAnnotations(annotations);
                    }
                }

                if (_precursorResultUpdater != null)
                {
                    var newResults = _precursorResultUpdater.Update(precursorDocNode.Results, precursor.Results);
                    precursorDocNode = precursorDocNode.ChangeResults(newResults);
                }
            }

            if (!RecurseTransitions)
            {
                return(precursorDocNode);
            }

            var newChildren = precursorDocNode.Transitions
                              .Select(transition => UpdateTransition(identityPath, transition)).ToArray();

            if (!ArrayUtil.ReferencesEqual(precursorDocNode.Children, newChildren))
            {
                precursorDocNode = (TransitionGroupDocNode)precursorDocNode.ChangeChildren(newChildren);
            }

            return(precursorDocNode);
        }