예제 #1
0
        /// <inheritdoc/>
        public bool UpdateTarget(ModelContainer modelContainer)
        {
            if (TargetNode == null)
            {
                var guid = modelContainer.GetGuid(ObjectValue, Type);
                if (TargetGuid != guid)
                {
                    throw new InvalidOperationException("The Guid of the object value is different from the current TargetGuid. The given ModelContainer may be different.");
                }

                if (TargetGuid != Guid.Empty)
                {
                    TargetNode = modelContainer.GetModelNode(TargetGuid);
                    if (TargetNode.Content.Value != null && !Type.IsInstanceOfType(TargetNode.Content.Value))
                    {
                        throw new InvalidOperationException("The type of the node content does not match the type of this reference");
                    }

                    return(TargetNode != null);
                }
            }
            return(false);
        }