Пример #1
0
        /// <summary>
        /// Search for the entity node that represents the entity in the given state.
        /// Returns null if not found.
        /// </summary>
        private static EntityNode FindNodeForState(IEntityState state, TreeNodeCollection nodes)
        {
            var result = nodes.OfType <EntityNode>().FirstOrDefault(x => state.IsStateOf(x.Entity));

            if (result != null)
            {
                return(result);
            }
            return(nodes.Cast <TreeNode>().Select(x => FindNodeForState(state, x.Nodes)).FirstOrDefault(x => x != null));
        }