public OpResult <Project> GetProject(Guid projectId) { var projectsConfigsList = _projectsConfigListFileConverter .Read(_configuration.ProjectsListPath) .Object; var projectConfig = projectsConfigsList.SingleOrDefault(c => c.Id == projectId); if (projectConfig == null) { return(OpResult <Project> .Bad(ErrorCode.PROJECT_DOES_NOT_EXIST, $"Project with id {projectId} not found in your configuration")); } var projectResult = _projectFileConverter.Read(Path.Combine(projectConfig.Path, _configuration.DefaultProjectFileName)); var rootPackNode = projectResult.Object.Tree as PackNode; if (rootPackNode != null) { for (int i = 0; i < rootPackNode.Children.Count; i++) { var recursionContext = new NodeRecursionContext { ChildIndex = i, CurrentNode = rootPackNode.Children[i], ParentNode = rootPackNode, Project = projectConfig }; ReadSubTree(recursionContext); } } return(projectResult); }
private OpResult ReadSubTree(NodeRecursionContext context) { if (context.CurrentNode is PackNode) { var packNode = context.CurrentNode as PackNode; for (int i = 0; i < packNode.Children.Count; i++) { var recursionContext = new NodeRecursionContext { ChildIndex = i, CurrentNode = packNode.Children[i], ParentNode = packNode, Project = context.Project }; ReadSubTree(recursionContext); } } if (context.CurrentNode is RequestNode) { var requestNode = context.CurrentNode as RequestNode; var readResult = _annexFileConverter.Read <RequestNode>(Path.Combine(context.Project.Path, requestNode.Id.ToString()) + ".yml"); if (readResult.Success) { (context.ParentNode as PackNode).Children[context.ChildIndex] = readResult.Object; } } if (context.CurrentNode is ScriptNode) { var scriptNode = context.CurrentNode as ScriptNode; var readResult = _annexFileConverter.Read <ScriptNode>(Path.Combine(context.Project.Path, scriptNode.Id.ToString()) + ".yml"); if (readResult.Success) { (context.ParentNode as PackNode).Children[context.ChildIndex] = readResult.Object; } } return(OpResult.Ok); }