Exemplo n.º 1
0
        public void WriteToolset(Domain.Box.BoxGroup toolset)
        {
            string configDirectoryPath = Path.Join(_filePath, toolset.Name);

            if (!Directory.Exists(configDirectoryPath))
            {
                Directory.CreateDirectory(configDirectoryPath);
            }

            foreach (Box tool in toolset.Tools)
            {
                string toolPath = Path.Join(_filePath, toolset.Name, $"{tool.Name}.tool.json");
                System.IO.File.WriteAllText(toolPath, JsonConvert.SerializeObject(tool, Formatting.Indented));
            }
        }
Exemplo n.º 2
0
        public Dictionary <string, Domain.Box.BoxGroup> ReadToolsets()
        {
            Dictionary <string, Domain.Box.BoxGroup> toolSets = new Dictionary <string, Domain.Box.BoxGroup>();

            string[] toolDirectories = Directory.GetDirectories(_filePath);
            foreach (string toolDirectoryPath in toolDirectories)
            {
                string toolName = Path.GetFileName(toolDirectoryPath);
                Domain.Box.BoxGroup newBoxGroup = new Domain.Box.BoxGroup();

                string[] toolFiles = Directory.GetFiles(toolDirectoryPath, "*.tool.json");
                foreach (string toolFile in toolFiles)
                {
                    Box newBox = JsonConvert.DeserializeObject <Box>(System.IO.File.ReadAllText(toolFile));
                    newBoxGroup.Tools.Add(newBox);
                }

                newBoxGroup.Name   = toolName;
                toolSets[toolName] = newBoxGroup;
            }

            return(toolSets);
        }