Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ。
        /// </summary>
        /// <param name="node">データベースノードのインスタンス。</param>
        public DatabaseProperty(DatabaseTreeNode node)
            : base(node)
        {
            Definition = (DatabaseDefinition)node.Tag;

            Name = Definition.Name;

            Func<TreeNode, ProjectTreeNode> recursive = null;
            recursive = (parent) =>
            {
                if (parent == null) return null;

                if (parent is ProjectTreeNode) return (ProjectTreeNode)parent;
                return recursive(parent.Parent);
            };

            Project = (WarlockProject)recursive(node).Tag;

            try
            {
                var data = Project.LoadDatabase(Definition);

                if (data is DatabaseClassData)
                {
                    _DataCount = 1;
                }
                else if (data is List<dynamic>)
                {
                    _DataCount = (
                        from d in (List<dynamic>)data
                        where d != null
                        select d
                    ).Count();
                }
                else if (data is Dictionary<dynamic, dynamic>)
                {
                    _DataCount = (
                        from d in (Dictionary<dynamic, dynamic>)data
                        where d.Value != null
                        select d
                    ).Count();
                }
            }
            catch (Exception) { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ノードを生成する。
        /// </summary>
        /// <param name="definition">データベース定義のインスタンス。</param>
        /// <returns>生成したツリーノード。</returns>
        public static DatabaseTreeNode Create(DatabaseDefinition definition)
        {
            var ret = new DatabaseTreeNode();

            ret.ImageKey = "DatabaseIcon.ico";
            ret.SelectedImageKey = ret.ImageKey;
            ret.Refresh(definition);

            return ret;
        }