private static Node AddDynamicNode(NodeTree tree, MetadataIdentity identity, IBindingMetadata metadata) { AddStaticNode(tree, metadata); Node thisNode = tree.FindNode(identity); MetadataIdentity parentIdentity = identity.Pop(); if (thisNode != null) { return(thisNode); } else if (parentIdentity != null) { Node parentNode = tree.FindNode(parentIdentity) ?? AddDynamicNode(tree, parentIdentity, metadata); if (parentNode != null) { thisNode = new Node(identity, metadata) { IsDynamic = true, }; parentNode.Properties.Add(thisNode); tree.Nodes.Add(thisNode); } } return(thisNode); }
private static Node AddStaticNode(NodeTree tree, IBindingMetadata metadata) { Node thisNode = tree.FindNode(metadata); if (thisNode != null) { return(thisNode); } else if (metadata.HasFlag(BindingMetadataFlags.Item) || HasValidReference(metadata)) { thisNode = new Node(metadata) { IsDynamic = metadata.HasFlag(BindingMetadataFlags.Dynamic), }; tree.Nodes.Add(thisNode); tree.Items.Add(thisNode); } else if (metadata.HasFlag(BindingMetadataFlags.Model)) { thisNode = new Node(metadata) { IsDynamic = metadata.HasFlag(BindingMetadataFlags.Dynamic), }; tree.Nodes.Add(thisNode); tree.Items.Add(thisNode); } else { Node parentNode = tree.FindNode(metadata.Parent) ?? AddStaticNode(tree, metadata.Parent); if (parentNode != null) { thisNode = new Node(metadata) { IsDynamic = metadata.HasFlag(BindingMetadataFlags.Dynamic), }; parentNode.Properties.Add(thisNode); tree.Nodes.Add(thisNode); } } return(thisNode); }