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