public NnPlan( string name, RPath path, NnTemplate template, PlanType type = PlanType.NoPlan ) { this.Name = name; this.FSPath = path; this.Template = template; this.Type = type; tasks = new Dictionary <NnParam, NnTask>(); KernelInitialize(); Save(); }
public static NnPlan?Load(RPath path) { try { var planData = (SaveData)Util.DeserializeFromFile( path.SubPath(NnAgent.planFileName) ); Dictionary <NnParam, NnTask> tasks = new Dictionary <NnParam, NnTask>(); foreach (var taskId in planData.taskIds) { NnTask?task = NnTask.Load( path.SubPath("tasks").SubPath(taskId.Value) ); if (task != null) { tasks[taskId.Key] = task; } } NnTemplate?template = NnTemplate.Load(path); if (template == null) { throw new Exception(); } NnPlan plan = new NnPlan( planData.name, path, template, tasks, // planData.consts?.ToImmutableDictionary(), planData.Type ); return(plan); } catch { Util.ErrorHappend($"Error while loading plan!"); return(null); } }
NnPlan( string name, RPath path, NnTemplate template, Dictionary <NnParam, NnTask> tasks, // ImmutableDictionary<string, string> ? consts, PlanType type ) { this.Name = name; this.FSPath = path; this.Template = template; this.tasks = tasks; // this.Consts = consts; this.Type = type; KernelInitialize(); Save(); }
public NnTemplateData?AddTemplate(string id, string content) { var template = NnTemplate.NewTemplate( id, content, project.FSPath.SubPath("templates").SubPath(id) ); if (template == null) { return(null); } if (project.AddTemplate(template)) { return(new NnTemplateData(template)); } else { return(null); } }
public static NnTemplate?Load(RPath path) { try { var tempData = (SaveData)Util.DeserializeFromFile( path.SubPath(NnAgent.tempFileName) ); NnTemplate temp = new NnTemplate( tempData.name, tempData.type, path, tempData.elements, tempData.variables.ToImmutableDictionary(), tempData.derivedVariables.ToImmutableDictionary() ); return(temp); } catch { Util.ErrorHappend($"Error while loading template!"); return(null); } }
public bool IsRef(NnTemplate data) => this.Template == data;
public NnTemplateData(NnTemplate template) { this.Template = template; }