public SaveData(NnPlan plan) { name = plan.Name; Type = plan.Type; taskIds = plan.tasks.ToDictionary(x => x.Key, x => x.Value.Name); // consts = plan.Consts != null ? // new Dictionary<string, string>(plan.Consts) : // null; }
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); } }
public NnPlanData?AddPlan(string planIdBase, NnTemplateData template, string?content = null) { // FIXME: ommiting planType! var temp = UnBox(template); if (temp == null) { return(null); } // FIXME: plan name logic string planId = planIdBase; int counter = 1; while (project.Plans.Where(x => x.Name == planId).Count() != 0) { planId = planIdBase + "_" + (counter++).ToString(); } var plan = new NnPlan( planId, project.FSPath.SubPath("plans").SubPath(planId), temp ); if (plan == null) { return(null); } if (project.AddPlan(plan)) { return(new NnPlanData(plan)); } else { return(null); } }
public bool IsRef(NnPlan data) => this.Plan == data;
public NnPlanData(NnPlan plan) { this.Plan = plan; Subscribe(plan); }