Exemple #1
0
        /// <summary>
        /// Gets the model associated to a data object, if it exists. If the ModelContainer has been constructed without <see cref="IGuidContainer"/>, this method will throw an exception.
        /// </summary>
        /// <param name="rootObject">The data object.</param>
        /// <returns>The <see cref="IModelNode"/> associated to the given object if available, or <c>null</c> otherwise.</returns>
        public IModelNode GetModelNode(object rootObject)
        {
            if (guidContainer == null)
            {
                throw new InvalidOperationException("This ModelContainer has no GuidContainer and can't retrieve Guid associated to a data object.");
            }
            Guid guid = guidContainer.GetGuid(rootObject);

            return(guid == Guid.Empty ? null : GetModelNode(guid));
        }
Exemple #2
0
 /// <summary>
 /// Gets the <see cref="IGraphNode"/> associated to a data object, if it exists. If the NodeContainer has been constructed without <see cref="IGuidContainer"/>, this method will throw an exception.
 /// </summary>
 /// <param name="rootObject">The data object.</param>
 /// <returns>The <see cref="IGraphNode"/> associated to the given object if available, or <c>null</c> otherwise.</returns>
 public IGraphNode GetNode(object rootObject)
 {
     lock (lockObject)
     {
         if (guidContainer == null)
         {
             throw new InvalidOperationException("This NodeContainer has no GuidContainer and can't retrieve Guid associated to a data object.");
         }
         var guid = guidContainer.GetGuid(rootObject);
         return(guid == Guid.Empty ? null : GetNode(guid));
     }
 }
Exemple #3
0
        /// <summary>
        /// Gets the <see cref="IGraphNode"/> associated to a data object, if it exists. If the NodeContainer has been constructed without <see cref="IGuidContainer"/>, this method will throw an exception.
        /// </summary>
        /// <param name="rootObject">The data object.</param>
        /// <returns>The <see cref="IGraphNode"/> associated to the given object if available, or <c>null</c> otherwise.</returns>
        internal IGraphNode GetNodeInternal(object rootObject)
        {
            lock (lockObject)
            {
                if (guidContainer == null)
                {
                    throw new InvalidOperationException("This NodeContainer has no GuidContainer and can't retrieve Guid associated to a data object.");
                }
                var guid = guidContainer.GetGuid(rootObject);
                if (guid == Guid.Empty)
                {
                    return(null);
                }

                IGraphNode node;
                if (nodesByGuid.TryGetValue(guid, out node))
                {
                    if (node != null && !processedNodes.Value.Contains(node))
                    {
                        UpdateReferencesInternal(node);
                    }
                }
                return(node);
            }
        }