コード例 #1
0
        /// <summary>
        /// 添加项目
        /// </summary>
        /// <param name="parent">父目录</param>
        /// <param name="name">名称</param>
        /// <param name="path">路径</param>
        public SlnInfo AddProject(SlnInfo parent, string name, string path)
        {
            var sln = new SlnInfo
            {
                Type         = SlnType.Project,
                Name         = name,
                RelativePath = path,
                ParentId     = parent.Id,
                Parent       = parent
            };

            parent.Childrens.Add(sln);
            return(sln);
        }
コード例 #2
0
        /// <summary>
        /// 添加解决方案文件夹
        /// </summary>
        /// <param name="parent">父目录</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public SlnInfo AddDir(SlnInfo parent, string name)
        {
            if (parent.Type == SlnType.Project)
            {
                throw new ArgumentException($"{parent.Type} 不能是项目类型");
            }
            var sln = new SlnInfo
            {
                Type         = SlnType.Dir,
                Name         = name,
                RelativePath = name,
                ParentId     = parent.Type == SlnType.Root ? parent.Id : parent.ParentId,
                Parent       = parent
            };

            parent.Childrens.Add(sln);
            return(sln);
        }