/// <summary> /// Creates a GraphNode and adds it to ObjectGraphData /// </summary> /// <param name="type">The type of the instance that this GraphNode represents</param> /// <returns>The GraphNode instance that was created</returns> public GraphNode CreateGraphNode(Type type) { ExceptionUtilities.CheckArgumentNotNull(type, "type"); GraphNode node = new GraphNode(type, this); this.graphNodes.Add(node); return node; }
/// <summary> /// Creates a GraphNode for the instance passed in /// and adds it to ObjectGraphData /// </summary> /// <param name="instance">The instance</param> /// <returns>The GraphNode instance that was created</returns> public GraphNode CreateGraphNode(object instance) { ExceptionUtilities.CheckArgumentNotNull(instance, "instance"); GraphNode node = new GraphNode(instance, this); this.graphNodes.Add(node); return node; }
/// <summary> /// Tries the get GraphNode based on the underlying instance /// </summary> /// <param name="instance">The instance.</param> /// <param name="graphNode">The graph node.</param> /// <returns>true, if the GraphNode corresponding to the instance was found, false if not</returns> public bool TryGetGraphNode(object instance, out GraphNode graphNode) { ExceptionUtilities.CheckArgumentNotNull(instance, "instance"); graphNode = this.graphNodes.Where(e => object.ReferenceEquals(e.Instance, instance)).SingleOrDefault(); return graphNode != null; }