Exemple #1
0
        public HierarchyComponentFile CreateFile(string[] path, string id)
        {
            string name = path[0];

            if (path.Length > 1)
            {
                System.Console.WriteLine($"Folder {name}");
                // Folder
                HierarchyComponentFolder folder = GetOrCreateFolder(name);
                return(folder.CreateFile(path.RemoveAt(0), id));
            }
            else
            {
                System.Console.WriteLine($"File {name}");
                // File
                HierarchyComponentFile file = AddFile(name, id);
                return(file);
            }
        }
Exemple #2
0
        public HierarchyComponentFile AddFile(string name, string id, bool overwrite = false, int stack = 2)
        {
            HierarchyComponentFile file = GetFile(name);

            if (file is null)
            {
                file = new HierarchyComponentFile(name, id);
                Entries.Add(file);
                return(file);
            }
            else if (overwrite && stack > 0)
            {
                Entries.Remove(file);
                return(AddFile(name, id, true, stack - 1));
            }
            else
            {
                return(null);
            }
        }