Ejemplo n.º 1
0
        /// <summary>
        /// Конструктор ветки
        /// </summary>
        /// <param name="project">путь к проекту</param>
        /// <param name="branch">путь к данной ветке</param>
        public Branch(string project, string branch)
        {
            this.projectPath = project;
            this.branchPath  = branch;

            FindFile(this.projectPath + this.branchPath);

            string[] branchMas  = branch.Split('\\');
            string   nameBranch = branchMas[branchMas.Length - 1];

            filesNode = new FileStruct(nameBranch);

            int countChars = (this.projectPath + this.branchPath).Length - (nameBranch).Length;

            foreach (FileProject filePath in fileBranch)
            {
                //если совпадает тогда добавляем ***доп проверка на целостность путей***
                if (filePath.GetPath.StartsWith(this.projectPath))
                {
                    filesNode.AddPath(filePath.GetPath.Remove(0, countChars));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// преобразовать в Node
        /// </summary>
        /// <param name="fileStruct">Элемент структуры</param>
        /// <returns>Дерево нодов относительно этого элемента</returns>
        private TreeNode ConverToTreeNode(FileStruct fileStruct)
        {
            TreeNode[] NodeCollection = null;
            if (fileStruct.next.Count > 0)
            {
                NodeCollection = new TreeNode[fileStruct.next.Count];
                int i = 0;
                foreach (FileStruct f in fileStruct.next)
                {
                    NodeCollection[i] = ConverToTreeNode(f);
                    i++;
                }
            }

            if (NodeCollection != null)
            {
                return(new TreeNode(fileStruct.Name, NodeCollection));
            }
            else
            {
                return(new TreeNode(fileStruct.Name));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Добавляем или ищем елемент
        /// </summary>
        /// <param name="root">узел</param>
        /// <param name="path">путь к узлу</param>
        /// <returns></returns>
        private bool AddElement(FileStruct root, string[] path)
        {
            //если еще есть елементы
            if (path.Length > 0)
            {
                string[] newPath;
                Array.Copy(path, 1, newPath = new string[path.Length - 1], 0, newPath.LongLength);

                //если такой элемент существует
                FileStruct next = root.IsNext(path[0]);
                //если нет
                if (next == null)
                {
                    //создаем
                    next = root.NewNext(path[0]);
                }
                //следующий блок
                return(AddElement(next, newPath));
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Конструктор элемента структуры файлов
 /// </summary>
 /// <param name="Name">Имя элемента</param>
 public FileStruct(string Name)
 {
     name = Name;
     root = this;
 }