Esempio n. 1
0
        internal void Refresh([NotNull] IGraphNode ownerNode, NodeContainer nodeContainer, NodeIndex index)
        {
            var objectValue = ownerNode.Retrieve(index);

            var boxedTarget = TargetNode as BoxedNode;

            if (boxedTarget != null && objectValue?.GetType() == TargetNode.Type)
            {
                // If we are boxing a struct, and the targeted type didn't change, we reuse the same nodes and just overwrite the struct value.
                boxedTarget.UpdateFromOwner(objectValue);
                // But we still need to refresh inner references!
                foreach (var member in TargetNode.Members.Where(x => x.IsReference))
                {
                    nodeContainer?.UpdateReferences(member);
                }
            }
            else if (TargetNode?.Retrieve() != objectValue)
            {
                // This call will recursively update the references.
                var target = SetTarget(objectValue, nodeContainer);
                if (target != null)
                {
                    var boxedContent = target as BoxedNode;
                    boxedContent?.SetOwnerContent(ownerNode, index);
                }
            }
            // This reference is not orphan anymore.
            orphanObject = null;
        }