Beispiel #1
0
        /// <summary>
        /// Set the <see cref="TargetNode"/> and <see cref="TargetGuid"/> of the targeted object by retrieving it from or creating it to the given <see cref="NodeContainer"/>.
        /// </summary>
        /// <param name="nodeContainer">The <see cref="NodeContainer"/> used to retrieve or create the target node.</param>
        /// <param name="nodeFactory">The factory to use to create nodes.</param>
        internal IGraphNode SetTarget(NodeContainer nodeContainer, NodeFactoryDelegate nodeFactory)
        {
            if (nodeContainer == null)
            {
                throw new ArgumentNullException(nameof(nodeContainer));
            }
            IGraphNode targetNode = nodeContainer.GetOrCreateNodeInternal(ObjectValue, nodeFactory);

            if (targetNode != null)
            {
                if (targetNode.Content.Value != null && !Type.IsInstanceOfType(targetNode.Content.Value))
                {
                    throw new InvalidOperationException(@"The type of the retrieved node content does not match the type of this reference");
                }

                // TODO: Disabled this exception which is triggered when a circular reference is made. This will be properly fixed when we'll get rid of the ShouldProcessReference mechanism.
                //if (TargetNode != null || TargetGuid != Guid.Empty)
                //    throw new InvalidOperationException("TargetNode has already been set.");

                if (targetNode.Content.Value != null && !Type.IsInstanceOfType(targetNode.Content.Value))
                {
                    throw new InvalidOperationException("TargetNode type does not match the reference type.");
                }

                TargetNode = targetNode;
                TargetGuid = targetNode.Guid;
            }
            return(targetNode);
        }
Beispiel #2
0
        internal IGraphNode SetTarget(object objectValue, [NotNull] NodeContainer nodeContainer)
        {
            if (nodeContainer == null)
            {
                throw new ArgumentNullException(nameof(nodeContainer));
            }
            var targetNode = nodeContainer.GetOrCreateNodeInternal(objectValue);

            SetTarget(targetNode);
            return(targetNode);
        }
Beispiel #3
0
        /// <summary>
        /// Set the <see cref="TargetNode"/> and <see cref="TargetGuid"/> of the targeted object by retrieving it from or creating it to the given <see cref="NodeContainer"/>.
        /// </summary>
        /// <param name="objectValue">The value for which to set the target node.</param>
        /// <param name="nodeContainer">The <see cref="NodeContainer"/> used to retrieve or create the target node.</param>
        /// <param name="nodeFactory">The factory to use to create nodes.</param>
        internal IGraphNode SetTarget(object objectValue, NodeContainer nodeContainer, NodeFactoryDelegate nodeFactory)
        {
            if (nodeContainer == null)
            {
                throw new ArgumentNullException(nameof(nodeContainer));
            }
            IGraphNode targetNode = nodeContainer.GetOrCreateNodeInternal(objectValue, nodeFactory);

            SetTarget(targetNode);
            return(targetNode);
        }
 /// <summary>
 /// Set the <see cref="TargetNode"/> and <see cref="TargetGuid"/> of the targeted object by retrieving it from or creating it to the given <see cref="NodeContainer"/>.
 /// </summary>
 /// <param name="objectValue">The value for which to set the target node.</param>
 /// <param name="nodeContainer">The <see cref="NodeContainer"/> used to retrieve or create the target node.</param>
 /// <param name="nodeFactory">The factory to use to create nodes.</param>
 internal IGraphNode SetTarget(object objectValue, NodeContainer nodeContainer, NodeFactoryDelegate nodeFactory)
 {
     if (nodeContainer == null) throw new ArgumentNullException(nameof(nodeContainer));
     IGraphNode targetNode = nodeContainer.GetOrCreateNodeInternal(objectValue, nodeFactory);
     SetTarget(targetNode);
     return targetNode;
 }