Import from internal git
This commit is contained in:
47
Core/Process/GenerationProcess.cs
Normal file
47
Core/Process/GenerationProcess.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using Core.SpecConfig;
|
||||
|
||||
namespace Core.Process;
|
||||
|
||||
public class GenerationProcess : IEnumerable
|
||||
{
|
||||
public ISpecFile BaseFile { get; private set; }
|
||||
private List<ProcessTask> _tasks;
|
||||
private PublishType _publishType;
|
||||
private GenerationType? _generationType;
|
||||
|
||||
public GenerationProcess(ISpecFile spec, PublishType pubType, GenerationType? genType)
|
||||
{
|
||||
BaseFile = spec;
|
||||
_tasks = RetrieveTasks();
|
||||
_publishType = pubType;
|
||||
_generationType = genType;
|
||||
}
|
||||
|
||||
private List<ProcessTask> RetrieveTasks()
|
||||
{
|
||||
var res = new List<ProcessTask>();
|
||||
|
||||
foreach (Language language in Enum.GetValues(typeof(Language)))
|
||||
{
|
||||
foreach (GenerationType type in Enum.GetValues(typeof(GenerationType)))
|
||||
{
|
||||
var tasks = BaseFile.GetTasksBy(language, type);
|
||||
if (tasks.Count == 0) continue;
|
||||
res.Add(new ProcessTask(language, type, _publishType, tasks));
|
||||
}
|
||||
}
|
||||
|
||||
return _generationType == null ? res
|
||||
: res.Where(p => p.GenerationType == _generationType).ToList();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
public ProcessEnumerator GetEnumerator()
|
||||
{
|
||||
_tasks = RetrieveTasks();
|
||||
return new ProcessEnumerator(_tasks);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user