public static Implementations.InjectionPlan.InjectionPlan Deserialize(IClassHierarchy ch, InjectionPlan ip) { string fullName = ip.name; if (ip.constructor != null) { Constructor cons = ip.constructor; IClassNode cn = (IClassNode)ch.GetNode(fullName); InjectionPlan[] protoBufArgs = cons.args.ToArray(); IClassNode[] cnArgs = new IClassNode[protoBufArgs.Length]; for (int i = 0; i < protoBufArgs.Length; i++) { INode no = ch.GetNode(protoBufArgs[i].name); if (no is IClassNode) { cnArgs[i] = (IClassNode)no; } else if (no is INamedParameterNode) { INamedParameterNode np = (INamedParameterNode)no; cnArgs[i] = (IClassNode)ch.GetNode(np.GetFullArgName()); } } Implementations.InjectionPlan.InjectionPlan[] ipArgs = new Implementations.InjectionPlan.InjectionPlan[protoBufArgs.Length]; for (int i = 0; i < protoBufArgs.Length; i++) { ipArgs[i] = (Implementations.InjectionPlan.InjectionPlan)Deserialize(ch, protoBufArgs[i]); } IConstructorDef constructor = cn.GetConstructorDef(cnArgs); return(new Implementations.InjectionPlan.Constructor(cn, constructor, ipArgs)); } if (ip.instance != null) { Instance ins = ip.instance; object instance = Parse(ip.name, ins.value); return(new CsInstance(ch.GetNode(ip.name), instance)); } if (ip.subplan != null) { Subplan subplan = ip.subplan; InjectionPlan[] protoBufPlans = subplan.plans.ToArray(); Implementations.InjectionPlan.InjectionPlan[] subPlans = new Implementations.InjectionPlan.InjectionPlan[protoBufPlans.Length]; for (int i = 0; i < protoBufPlans.Length; i++) { subPlans[i] = (Implementations.InjectionPlan.InjectionPlan)Deserialize(ch, protoBufPlans[i]); } INode n = ch.GetNode(fullName); return(new Implementations.InjectionPlan.Subplan(n, subPlans)); } Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Encountered unknown type of InjectionPlan: " + ip), LOGGER); return(null); }
private static InjectionPlan NewSubplan(string fullName, int selectedPlan, List <InjectionPlan> plans) { Subplan subPlan = new Subplan(); subPlan.selected_plan = selectedPlan; foreach (InjectionPlan p in plans) { subPlan.plans.Add(p); } InjectionPlan plan = new InjectionPlan(); plan.name = fullName; plan.subplan = subPlan; return(plan); }